Skip to content

Commit

Permalink
refactor: refactor MongoDB client connection
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
appleboy committed Oct 9, 2023
1 parent 8fca474 commit f378232
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions mongo/mongodriver/mongodriver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ const mongoTestServer = "mongodb://localhost:27017"
var newStore = func(_ *testing.T) sessions.Store {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
client, err := mongo.NewClient(options.Client().ApplyURI(mongoTestServer))
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoTestServer))
if err != nil {
panic(err)
}

if err := client.Connect(ctx); err != nil {
panic(err)
}

c := client.Database("test").Collection("sessions")
return NewStore(c, 3600, true, []byte("secret"))
}
Expand Down

0 comments on commit f378232

Please sign in to comment.