Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Dec 19, 2023
1 parent f75e28d commit 813b2f4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions integration/users/drop_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
Expand All @@ -39,21 +38,21 @@ func TestDropUser(t *testing.T) {

// TODO https://github.com/FerretDB/FerretDB/issues/1492
if setup.IsMongoDB(t) {
assert.NoError(t, collection.Database().RunCommand(ctx, bson.D{
require.NoError(t, collection.Database().RunCommand(ctx, bson.D{
{"dropAllUsersFromDatabase", 1},
}).Err())
} else {
// Erase any previously saved user in the database.
_, err := users.DeleteMany(ctx, bson.D{{"db", db.Name()}})
assert.NoError(t, err)
require.NoError(t, err)
}

err := db.RunCommand(ctx, bson.D{
{"createUser", "a_user"},
{"roles", bson.A{}},
{"pwd", "password"},
}).Err()
assert.NoError(t, err)
require.NoError(t, err)

testCases := map[string]struct { //nolint:vet // for readability
payload bson.D
Expand Down Expand Up @@ -111,6 +110,6 @@ func TestDropUser(t *testing.T) {
// assertUserNotFound checks it the user doesn't exist in the admin.system.users collection.
func assertUserNotFound(ctx context.Context, t testing.TB, users *mongo.Collection, dbName, username string) {
t.Helper()
err := users.FindOne(ctx, bson.D{{"user", username}}).Err()
err := users.FindOne(ctx, bson.D{{"user", username}, {"db", dbName}}).Err()
require.Equal(t, mongo.ErrNoDocuments, err, `should return "no documents" error`)
}

0 comments on commit 813b2f4

Please sign in to comment.