INNER CODE UNIT · Go
TestClient_e2e_NewClient
chenmingyong0423/go-mongox · client_e2e_test.go:31
func TestClient_e2e_NewClient(t *testing.T) {
c, err := mongo.Connect(options.Client().ApplyURI("mongodb://localhost:27017").SetAuth(options.Credential{
Username: "test",
Password: "test",
AuthSource: "db-test",
}))
require.NoError(t, err)
client := NewClient(c, &Config{})
err = client.Client().Ping(context.Background(), readpref.Primary())
require.NoError(t, err)
require.NotNil(t, client.config())
require.NotNil(t, client.NewDatabase("db-test"))
err = client.Disconnect(context.Background())
require.NoError(t, err)
}