Fix issues with new version of MongoDB driver:

- "connect=single" option is no longer supported
        - "connect=direct" is the equivalent
        - https://jira.mongodb.org/browse/GODRIVER-665
    - Count() needs to be passed a non-nil filter/document
        - https://jira.mongodb.org/browse/GODRIVER-572
This commit is contained in:
Dale Hui 2019-03-01 16:39:45 -08:00
parent 4fba554b47
commit 5e004dbef4

View File

@ -37,7 +37,7 @@ var (
func mongoConnectionString(host, port string) string {
// there is connect option for excluding serverConnection algorithm
// it's let avoid errors with mongo replica set connection in docker container
return fmt.Sprintf("mongodb://%s:%s/testMigration?connect=single", host, port)
return fmt.Sprintf("mongodb://%s:%s/testMigration?connect=direct", host, port)
}
func isReady(ctx context.Context, c dktest.ContainerInfo) bool {
@ -265,7 +265,7 @@ func TestTransaction(t *testing.T) {
t.Fatalf("%v", runErr)
}
}
documentsCount, err := client.Database("testMigration").Collection("hello").Count(context.TODO(), nil)
documentsCount, err := client.Database("testMigration").Collection("hello").Count(context.TODO(), bson.M{})
if err != nil {
t.Fatalf("%v", err)
}