Skip to content

Commit

Permalink
Minor tweaks to buildInfo command
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Jan 15, 2022
1 parent 563031c commit ba59015
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 5 additions & 2 deletions internal/handlers/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/FerretDB/FerretDB/internal/handlers/sql"
"github.com/FerretDB/FerretDB/internal/pg"
"github.com/FerretDB/FerretDB/internal/types"
"github.com/FerretDB/FerretDB/internal/util/must"
"github.com/FerretDB/FerretDB/internal/util/testutil"
"github.com/FerretDB/FerretDB/internal/util/version"
"github.com/FerretDB/FerretDB/internal/wire"
Expand Down Expand Up @@ -429,12 +430,14 @@ func TestReadOnlyHandlers(t *testing.T) {
resp: types.MustMakeDocument(
"version", "5.0.42",
"gitVersion", version.Get().Commit,
"versionArray", types.MustNewArray(int32(5), int32(0), int32(42), int32(0)),
"modules", must.NotFail(types.NewArray()),
"sysInfo", "deprecated",
"versionArray", must.NotFail(types.NewArray(int32(5), int32(0), int32(42), int32(0))),
"bits", int32(strconv.IntSize),
"debug", version.Get().Debug,
"maxBsonObjectSize", int32(16777216),
"buildEnvironment", must.NotFail(types.MakeDocument()),
"ok", float64(1),
"buildEnvironment", types.MustMakeDocument(),
),
},

Expand Down
4 changes: 3 additions & 1 deletion internal/handlers/msg_buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ func (h *Handler) MsgBuildInfo(ctx context.Context, msg *wire.OpMsg) (*wire.OpMs
Documents: []types.Document{types.MustMakeDocument(
"version", versionValue,
"gitVersion", version.Get().Commit,
"modules", types.MustNewArray(),
"sysInfo", "deprecated",
"versionArray", must.NotFail(types.NewArray(int32(5), int32(0), int32(42), int32(0))),
"bits", int32(strconv.IntSize),
"debug", version.Get().Debug,
"maxBsonObjectSize", int32(types.MaxDocumentLen),
"ok", float64(1),
"buildEnvironment", version.Get().BuildEnvironment,
"ok", float64(1),
)},
})
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/types/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ func ConvertDocument(d document) (Document, error) {
}

// MustConvertDocument is a ConvertDocument that panics in case of error.
//
// Deprecated: use `must.NotFail(ConvertDocument(...))` instead.
func MustConvertDocument(d document) Document {
doc, err := ConvertDocument(d)
if err != nil {
Expand Down Expand Up @@ -114,6 +116,8 @@ func MakeDocument(pairs ...any) (Document, error) {
}

// MustMakeDocument is a MakeDocument that panics in case of error.
//
// Deprecated: use `must.NotFail(MakeDocument(...))` instead.
func MustMakeDocument(pairs ...any) Document {
doc, err := MakeDocument(pairs...)
if err != nil {
Expand Down

0 comments on commit ba59015

Please sign in to comment.