@@ -31,20 +31,6 @@ func requireCursorLength(t *testing.T, cursor mongo.Cursor, length int) {
31
31
require .Equal (t , i , length )
32
32
}
33
33
34
- func stringSliceEquals (s1 []string , s2 []string ) bool {
35
- if len (s1 ) != len (s2 ) {
36
- return false
37
- }
38
-
39
- for i := range s1 {
40
- if s1 [i ] != s2 [i ] {
41
- return false
42
- }
43
- }
44
-
45
- return true
46
- }
47
-
48
34
func containsKey (doc bsonx.Doc , key ... string ) bool {
49
35
_ , err := doc .LookupErr (key ... )
50
36
if err != nil {
@@ -53,6 +39,7 @@ func containsKey(doc bsonx.Doc, key ...string) bool {
53
39
return true
54
40
}
55
41
42
+ // InsertExamples contains examples for insert operations.
56
43
func InsertExamples (t * testing.T , db * mongo.Database ) {
57
44
err := db .RunCommand (
58
45
context .Background (),
@@ -144,6 +131,7 @@ func InsertExamples(t *testing.T, db *mongo.Database) {
144
131
}
145
132
}
146
133
134
+ // QueryToplevelFieldsExamples contains examples for querying top-level fields.
147
135
func QueryToplevelFieldsExamples (t * testing.T , db * mongo.Database ) {
148
136
err := db .RunCommand (
149
137
context .Background (),
@@ -314,6 +302,7 @@ func QueryToplevelFieldsExamples(t *testing.T, db *mongo.Database) {
314
302
315
303
}
316
304
305
+ // QueryEmbeddedDocumentsExamples contains examples for querying embedded document fields.
317
306
func QueryEmbeddedDocumentsExamples (t * testing.T , db * mongo.Database ) {
318
307
err := db .RunCommand (
319
308
context .Background (),
@@ -477,6 +466,7 @@ func QueryEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
477
466
478
467
}
479
468
469
+ // QueryArraysExamples contains examples for querying array fields.
480
470
func QueryArraysExamples (t * testing.T , db * mongo.Database ) {
481
471
err := db .RunCommand (
482
472
context .Background (),
@@ -665,6 +655,7 @@ func QueryArraysExamples(t *testing.T, db *mongo.Database) {
665
655
666
656
}
667
657
658
+ // QueryArrayEmbeddedDocumentsExamples contains examples for querying fields with arrays and embedded documents.
668
659
func QueryArrayEmbeddedDocumentsExamples (t * testing.T , db * mongo.Database ) {
669
660
err := db .RunCommand (
670
661
context .Background (),
@@ -896,6 +887,7 @@ func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
896
887
}
897
888
}
898
889
890
+ // QueryNullMissingFieldsExamples contains examples for querying fields that are null or missing.
899
891
func QueryNullMissingFieldsExamples (t * testing.T , db * mongo.Database ) {
900
892
err := db .RunCommand (
901
893
context .Background (),
@@ -976,6 +968,7 @@ func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
976
968
}
977
969
}
978
970
971
+ // ProjectionExamples contains examples for specifying projections in find operations.
979
972
func ProjectionExamples (t * testing.T , db * mongo.Database ) {
980
973
err := db .RunCommand (
981
974
context .Background (),
@@ -1115,7 +1108,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1115
1108
doc := bsonx.Doc {}
1116
1109
for cursor .Next (context .Background ()) {
1117
1110
doc = doc [:0 ]
1118
- err := cursor .Decode (doc )
1111
+ err := cursor .Decode (& doc )
1119
1112
require .NoError (t , err )
1120
1113
1121
1114
require .True (t , containsKey (doc , "_id" ))
@@ -1152,7 +1145,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1152
1145
doc := bsonx.Doc {}
1153
1146
for cursor .Next (context .Background ()) {
1154
1147
doc = doc [:0 ]
1155
- err := cursor .Decode (doc )
1148
+ err := cursor .Decode (& doc )
1156
1149
require .NoError (t , err )
1157
1150
1158
1151
require .False (t , containsKey (doc , "_id" ))
@@ -1188,7 +1181,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1188
1181
doc := bsonx.Doc {}
1189
1182
for cursor .Next (context .Background ()) {
1190
1183
doc = doc [:0 ]
1191
- err := cursor .Decode (doc )
1184
+ err := cursor .Decode (& doc )
1192
1185
require .NoError (t , err )
1193
1186
1194
1187
require .True (t , containsKey (doc , "_id" ))
@@ -1225,7 +1218,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1225
1218
doc := bsonx.Doc {}
1226
1219
for cursor .Next (context .Background ()) {
1227
1220
doc = doc [:0 ]
1228
- err := cursor .Decode (doc )
1221
+ err := cursor .Decode (& doc )
1229
1222
require .NoError (t , err )
1230
1223
1231
1224
require .True (t , containsKey (doc , "_id" ))
@@ -1234,7 +1227,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1234
1227
require .True (t , containsKey (doc , "size" ))
1235
1228
require .False (t , containsKey (doc , "instock" ))
1236
1229
1237
- require .True (t , containsKey (doc , "uom " , "size " ))
1230
+ require .True (t , containsKey (doc , "size " , "uom " ))
1238
1231
require .False (t , containsKey (doc , "h" , "size" ))
1239
1232
require .False (t , containsKey (doc , "w" , "size" ))
1240
1233
@@ -1265,7 +1258,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1265
1258
doc := bsonx.Doc {}
1266
1259
for cursor .Next (context .Background ()) {
1267
1260
doc = doc [:0 ]
1268
- err := cursor .Decode (doc )
1261
+ err := cursor .Decode (& doc )
1269
1262
require .NoError (t , err )
1270
1263
1271
1264
require .True (t , containsKey (doc , "_id" ))
@@ -1275,8 +1268,8 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1275
1268
require .True (t , containsKey (doc , "instock" ))
1276
1269
1277
1270
require .False (t , containsKey (doc , "uom" , "size" ))
1278
- require .True (t , containsKey (doc , "h " , "size " ))
1279
- require .True (t , containsKey (doc , "w " , "size " ))
1271
+ require .True (t , containsKey (doc , "size " , "h " ))
1272
+ require .True (t , containsKey (doc , "size " , "w " ))
1280
1273
1281
1274
}
1282
1275
@@ -1307,7 +1300,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1307
1300
doc := bsonx.Doc {}
1308
1301
for cursor .Next (context .Background ()) {
1309
1302
doc = doc [:0 ]
1310
- err := cursor .Decode (doc )
1303
+ err := cursor .Decode (& doc )
1311
1304
require .NoError (t , err )
1312
1305
1313
1306
require .True (t , containsKey (doc , "_id" ))
@@ -1360,7 +1353,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1360
1353
doc := bsonx.Doc {}
1361
1354
for cursor .Next (context .Background ()) {
1362
1355
doc = doc [:0 ]
1363
- err := cursor .Decode (doc )
1356
+ err := cursor .Decode (& doc )
1364
1357
require .NoError (t , err )
1365
1358
1366
1359
require .True (t , containsKey (doc , "_id" ))
@@ -1378,6 +1371,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
1378
1371
}
1379
1372
}
1380
1373
1374
+ // UpdateExamples contains examples of update operations.
1381
1375
func UpdateExamples (t * testing.T , db * mongo.Database ) {
1382
1376
err := db .RunCommand (
1383
1377
context .Background (),
@@ -1537,7 +1531,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
1537
1531
doc := bsonx.Doc {}
1538
1532
for cursor .Next (context .Background ()) {
1539
1533
doc = doc [:0 ]
1540
- err := cursor .Decode (doc )
1534
+ err := cursor .Decode (& doc )
1541
1535
require .NoError (t , err )
1542
1536
1543
1537
uom , err := doc .LookupErr ("size" , "uom" )
@@ -1594,7 +1588,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
1594
1588
doc := bsonx.Doc {}
1595
1589
for cursor .Next (context .Background ()) {
1596
1590
doc = doc [:0 ]
1597
- err := cursor .Decode (doc )
1591
+ err := cursor .Decode (& doc )
1598
1592
require .NoError (t , err )
1599
1593
1600
1594
uom , err := doc .LookupErr ("size" , "uom" )
@@ -1651,7 +1645,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
1651
1645
doc := bsonx.Doc {}
1652
1646
for cursor .Next (context .Background ()) {
1653
1647
doc = doc [:0 ]
1654
- err := cursor .Decode (doc )
1648
+ err := cursor .Decode (& doc )
1655
1649
require .NoError (t , err )
1656
1650
1657
1651
require .True (t , containsKey (doc , "_id" ))
@@ -1669,6 +1663,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
1669
1663
1670
1664
}
1671
1665
1666
+ // DeleteExamples contains examples of delete operations.
1672
1667
func DeleteExamples (t * testing.T , db * mongo.Database ) {
1673
1668
err := db .RunCommand (
1674
1669
context .Background (),
0 commit comments