Skip to content

Commit 03d16bb

Browse files
author
Isabella Siu
committed
Fix tests
Change-Id: I3aec90fd3355e388f24381a295bcb60da7cf0e22
1 parent 684be53 commit 03d16bb

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

mongo/collection_internal_test.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ func TestCollection_ReplaceTopologyError(t *testing.T) {
167167
db := c.Database("TestCollection")
168168
coll := db.Collection("ReplaceTopologyError")
169169

170-
doc1 := bson.NewDocument(bson.EC.Int32("x", 1))
171-
doc2 := bson.NewDocument(bson.EC.Int32("x", 6))
170+
doc1 := bsonx.Doc{{"x", bsonx.Int32(1)}}
171+
doc2 := bsonx.Doc{{"x", bsonx.Int32(6)}}
172172
docs := []interface{}{doc1, doc2}
173-
update := bson.NewDocument(
174-
bson.EC.SubDocumentFromElements("$inc", bson.EC.Int32("x", 1)))
173+
update := bsonx.Doc{
174+
{"$inc", bsonx.Document(bsonx.Doc{{"x", bsonx.Int32(1)}})},
175+
}
175176

176177
_, err = coll.InsertOne(context.Background(), doc1)
177178
require.Equal(t, err, ErrClientDisconnected)
@@ -194,16 +195,20 @@ func TestCollection_ReplaceTopologyError(t *testing.T) {
194195
_, err = coll.ReplaceOne(context.Background(), doc1, doc2)
195196
require.Equal(t, err, ErrClientDisconnected)
196197

197-
pipeline := bson.NewArray(
198-
bson.VC.DocumentFromElements(
199-
bson.EC.SubDocumentFromElements(
200-
"$match",
201-
bson.EC.SubDocumentFromElements(
202-
"x",
203-
bson.EC.Int32("$gte", 2),
204-
),
205-
),
206-
))
198+
pipeline := bsonx.Arr{
199+
bsonx.Document(
200+
bsonx.Doc{{"$match", bsonx.Document(bsonx.Doc{{"x", bsonx.Document(bsonx.Doc{{"$gte", bsonx.Int32(2)}})}})}},
201+
),
202+
bsonx.Document(
203+
bsonx.Doc{{
204+
"$project",
205+
bsonx.Document(bsonx.Doc{
206+
{"_id", bsonx.Int32(0)},
207+
{"x", bsonx.Int32(1)},
208+
}),
209+
}},
210+
)}
211+
207212
_, err = coll.Aggregate(context.Background(), pipeline, options.Aggregate())
208213
require.Equal(t, err, ErrClientDisconnected)
209214

mongo/database_internal_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestDatabase_ReplaceTopologyError(t *testing.T) {
117117

118118
db := c.Database("TestDatabase_ReplaceTopologyError")
119119

120-
_, err = db.RunCommand(context.Background(), bson.NewDocument(bson.EC.Int32("ismaster", 1)))
120+
_, err = db.RunCommand(context.Background(), bsonx.Doc{{"ismaster", bsonx.Int32(1)}})
121121
require.Equal(t, err, ErrClientDisconnected)
122122

123123
err = db.Drop(ctx)

0 commit comments

Comments
 (0)