Skip to content

Commit

Permalink
Move getParameter tests (#450)
Browse files Browse the repository at this point in the history
Refs #417.
  • Loading branch information
AlekSi committed Apr 6, 2022
1 parent e95eb88 commit 5db705e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 17 deletions.
3 changes: 1 addition & 2 deletions integration/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func TestInsertFind(t *testing.T) {
docs = append(docs, provider.Docs()...)
}

opts := options.Find().SetSort(bson.D{{"_id", 1}})
for _, expected := range docs {
expected := expected
id := expected.Map()["_id"]
Expand All @@ -83,7 +82,7 @@ func TestInsertFind(t *testing.T) {
t.Parallel()

var actual []bson.D
cursor, err := collection.Find(ctx, bson.D{{"_id", id}}, opts)
cursor, err := collection.Find(ctx, bson.D{{"_id", id}}, options.Find().SetSort(bson.D{{"_id", 1}}))
require.NoError(t, err)

err = cursor.All(ctx, &actual)
Expand Down
20 changes: 20 additions & 0 deletions integration/commands_administration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,23 @@ func TestCommandsAdministrationCreateDropList(t *testing.T) {
require.NoError(t, err)
assert.Contains(t, names, name)
}

func TestCommandsAdministrationGetParameter(t *testing.T) {
t.Parallel()
ctx, collection := setupWithOpts(t, &setupOpts{
databaseName: "admin",
})

var actual bson.D
err := collection.Database().RunCommand(ctx, bson.D{{"getParameter", "*"}}).Decode(&actual)
require.NoError(t, err)

m := actual.Map()
t.Log(m)

assert.Equal(t, 1.0, m["ok"])

keys := collectKeys(t, actual)
assert.Contains(t, keys, "quiet")
assert.Equal(t, false, m["quiet"])
}
4 changes: 2 additions & 2 deletions integration/query_array_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestQueryArraySize(t *testing.T) {
_, err := collection.InsertMany(ctx, []any{
bson.D{{"_id", "array-empty"}, {"value", bson.A{}}},
bson.D{{"_id", "array-one"}, {"value", bson.A{"1"}}},
bson.D{{"_id", "array-two"}, {"value", bson.A{"1", "2"}}},
bson.D{{"_id", "array-three"}, {"value", bson.A{"1", "2", "3"}}},
bson.D{{"_id", "array-two"}, {"value", bson.A{"1", nil}}},
bson.D{{"_id", "array-three"}, {"value", bson.A{"1", "2", math.NaN()}}},
bson.D{{"_id", "string"}, {"value", "12"}},
bson.D{{"_id", "document"}, {"value", bson.D{{"value", bson.A{"1", "2"}}}}},
})
Expand Down
3 changes: 1 addition & 2 deletions integration/query_bitwise_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func TestQueryBitwiseAllClear(t *testing.T) {
t.Parallel()
ctx, collection := setup(t, shareddata.Scalars)

opts := options.Find().SetSort(bson.D{{"_id", 1}})
for name, tc := range map[string]struct {
v any
expectedIDs []any
Expand All @@ -50,7 +49,7 @@ func TestQueryBitwiseAllClear(t *testing.T) {

var actual []bson.D
q := bson.D{{"value", bson.D{{"$bitsAllClear", tc.v}}}}
cursor, err := collection.Find(ctx, q, opts)
cursor, err := collection.Find(ctx, q, options.Find().SetSort(bson.D{{"_id", 1}}))
if tc.err != nil {
require.Nil(t, tc.expectedIDs)
require.Equal(t, tc.err, err)
Expand Down
10 changes: 0 additions & 10 deletions internal/handlers/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1505,16 +1505,6 @@ func TestReadOnlyHandlers(t *testing.T) {
},
},

"GetParameter": {
req: types.MustNewDocument(
"getParameter", int32(1),
),
resp: types.MustNewDocument(
"version", "5.0.42",
"ok", float64(1),
),
},

"ServerStatus": {
req: must.NotFail(types.NewDocument(
"serverStatus", int32(1),
Expand Down
4 changes: 3 additions & 1 deletion internal/handlers/pg/msg_getparameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ func (h *Handler) MsgGetParameter(ctx context.Context, msg *wire.OpMsg) (*wire.O
return nil, lazyerrors.Error(err)
}

// TODO https://github.com/FerretDB/FerretDB/issues/449

common.Ignored(document, h.l, "comment")

var reply wire.OpMsg
err = reply.SetSections(wire.OpMsgSection{
Documents: []*types.Document{types.MustNewDocument(
"version", versionValue,
"quiet", false,
"ok", float64(1),
)},
})
Expand Down

0 comments on commit 5db705e

Please sign in to comment.