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