Skip to content

Commit f378232

Browse files
committed
refactor: refactor MongoDB client connection
- Replace `mongo.NewClient` with `mongo.Connect` to create a new client - Remove the code block that connects the client Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent 8fca474 commit f378232

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

mongo/mongodriver/mongodriver_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ const mongoTestServer = "mongodb://localhost:27017"
1616
var newStore = func(_ *testing.T) sessions.Store {
1717
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
1818
defer cancel()
19-
client, err := mongo.NewClient(options.Client().ApplyURI(mongoTestServer))
19+
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoTestServer))
2020
if err != nil {
2121
panic(err)
2222
}
2323

24-
if err := client.Connect(ctx); err != nil {
25-
panic(err)
26-
}
27-
2824
c := client.Database("test").Collection("sessions")
2925
return NewStore(c, 3600, true, []byte("secret"))
3026
}

0 commit comments

Comments
 (0)