Skip to content

Commit 42e68e3

Browse files
committed
Revert "Update Makefile to run examples and fix bugs in examples."
This reverts commit 0cb0bd0. Reason for revert: Failing tests on Evergreen. Change-Id: I60063242fea97c603ed02e565493101e1afa38b3
1 parent 0f35742 commit 42e68e3

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

.lint-whitelist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,3 @@ bson/internal/jsonparser/parser.go:1137:9: if block ends with a return statement
6161
bson/internal/jsonparser/parser.go:1146:9: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
6262
bson/internal/jsonparser/parser_test.go:1361:5: var testJson should be testJSON
6363
bson/internal/jsonpretty/pretty.go:7:1: comment on exported type Options should be of the form "Options ..." (with optional leading article)
64-
examples/documentation_examples/examples.go:10:1: don't use an underscore in package name

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ UNSTABLE_PKGS = $(shell etc/list_pkgs.sh ./x)
66
UNSTABLE_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./x)
77
TAG_PKG = $(shell etc/list_pkgs.sh ./tag)
88
TAG_TEST_PKG = $(shell etc/list_test_pkgs.sh ./tag)
9-
EXAMPLES_PKGS = $(shell etc/list_pkgs.sh ./examples)
10-
EXAMPLES_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./examples)
11-
PKGS = $(BSON_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG) $(EXAMPLES_PKGS)
12-
TEST_PKGS = $(BSON_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG) $(EXAMPLES_TEST_PKGS)
9+
PKGS = $(BSON_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG)
10+
TEST_PKGS = $(BSON_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG)
1311

1412
TEST_TIMEOUT = 600
1513

examples/documentation_examples/examples.go

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ func requireCursorLength(t *testing.T, cursor mongo.Cursor, length int) {
3131
require.Equal(t, i, length)
3232
}
3333

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+
3448
func containsKey(doc bsonx.Doc, key ...string) bool {
3549
_, err := doc.LookupErr(key...)
3650
if err != nil {
@@ -39,7 +53,6 @@ func containsKey(doc bsonx.Doc, key ...string) bool {
3953
return true
4054
}
4155

42-
// InsertExamples contains examples for insert operations.
4356
func InsertExamples(t *testing.T, db *mongo.Database) {
4457
err := db.RunCommand(
4558
context.Background(),
@@ -131,7 +144,6 @@ func InsertExamples(t *testing.T, db *mongo.Database) {
131144
}
132145
}
133146

134-
// QueryToplevelFieldsExamples contains examples for querying top-level fields.
135147
func QueryToplevelFieldsExamples(t *testing.T, db *mongo.Database) {
136148
err := db.RunCommand(
137149
context.Background(),
@@ -302,7 +314,6 @@ func QueryToplevelFieldsExamples(t *testing.T, db *mongo.Database) {
302314

303315
}
304316

305-
// QueryEmbeddedDocumentsExamples contains examples for querying embedded document fields.
306317
func QueryEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
307318
err := db.RunCommand(
308319
context.Background(),
@@ -466,7 +477,6 @@ func QueryEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
466477

467478
}
468479

469-
// QueryArraysExamples contains examples for querying array fields.
470480
func QueryArraysExamples(t *testing.T, db *mongo.Database) {
471481
err := db.RunCommand(
472482
context.Background(),
@@ -655,7 +665,6 @@ func QueryArraysExamples(t *testing.T, db *mongo.Database) {
655665

656666
}
657667

658-
// QueryArrayEmbeddedDocumentsExamples contains examples for querying fields with arrays and embedded documents.
659668
func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
660669
err := db.RunCommand(
661670
context.Background(),
@@ -887,7 +896,6 @@ func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
887896
}
888897
}
889898

890-
// QueryNullMissingFieldsExamples contains examples for querying fields that are null or missing.
891899
func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
892900
err := db.RunCommand(
893901
context.Background(),
@@ -968,7 +976,6 @@ func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
968976
}
969977
}
970978

971-
// ProjectionExamples contains examples for specifying projections in find operations.
972979
func ProjectionExamples(t *testing.T, db *mongo.Database) {
973980
err := db.RunCommand(
974981
context.Background(),
@@ -1108,7 +1115,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
11081115
doc := bsonx.Doc{}
11091116
for cursor.Next(context.Background()) {
11101117
doc = doc[:0]
1111-
err := cursor.Decode(&doc)
1118+
err := cursor.Decode(doc)
11121119
require.NoError(t, err)
11131120

11141121
require.True(t, containsKey(doc, "_id"))
@@ -1145,7 +1152,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
11451152
doc := bsonx.Doc{}
11461153
for cursor.Next(context.Background()) {
11471154
doc = doc[:0]
1148-
err := cursor.Decode(&doc)
1155+
err := cursor.Decode(doc)
11491156
require.NoError(t, err)
11501157

11511158
require.False(t, containsKey(doc, "_id"))
@@ -1181,7 +1188,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
11811188
doc := bsonx.Doc{}
11821189
for cursor.Next(context.Background()) {
11831190
doc = doc[:0]
1184-
err := cursor.Decode(&doc)
1191+
err := cursor.Decode(doc)
11851192
require.NoError(t, err)
11861193

11871194
require.True(t, containsKey(doc, "_id"))
@@ -1218,7 +1225,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
12181225
doc := bsonx.Doc{}
12191226
for cursor.Next(context.Background()) {
12201227
doc = doc[:0]
1221-
err := cursor.Decode(&doc)
1228+
err := cursor.Decode(doc)
12221229
require.NoError(t, err)
12231230

12241231
require.True(t, containsKey(doc, "_id"))
@@ -1227,7 +1234,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
12271234
require.True(t, containsKey(doc, "size"))
12281235
require.False(t, containsKey(doc, "instock"))
12291236

1230-
require.True(t, containsKey(doc, "size", "uom"))
1237+
require.True(t, containsKey(doc, "uom", "size"))
12311238
require.False(t, containsKey(doc, "h", "size"))
12321239
require.False(t, containsKey(doc, "w", "size"))
12331240

@@ -1258,7 +1265,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
12581265
doc := bsonx.Doc{}
12591266
for cursor.Next(context.Background()) {
12601267
doc = doc[:0]
1261-
err := cursor.Decode(&doc)
1268+
err := cursor.Decode(doc)
12621269
require.NoError(t, err)
12631270

12641271
require.True(t, containsKey(doc, "_id"))
@@ -1268,8 +1275,8 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
12681275
require.True(t, containsKey(doc, "instock"))
12691276

12701277
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"))
12731280

12741281
}
12751282

@@ -1300,7 +1307,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
13001307
doc := bsonx.Doc{}
13011308
for cursor.Next(context.Background()) {
13021309
doc = doc[:0]
1303-
err := cursor.Decode(&doc)
1310+
err := cursor.Decode(doc)
13041311
require.NoError(t, err)
13051312

13061313
require.True(t, containsKey(doc, "_id"))
@@ -1353,7 +1360,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
13531360
doc := bsonx.Doc{}
13541361
for cursor.Next(context.Background()) {
13551362
doc = doc[:0]
1356-
err := cursor.Decode(&doc)
1363+
err := cursor.Decode(doc)
13571364
require.NoError(t, err)
13581365

13591366
require.True(t, containsKey(doc, "_id"))
@@ -1371,7 +1378,6 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
13711378
}
13721379
}
13731380

1374-
// UpdateExamples contains examples of update operations.
13751381
func UpdateExamples(t *testing.T, db *mongo.Database) {
13761382
err := db.RunCommand(
13771383
context.Background(),
@@ -1531,7 +1537,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
15311537
doc := bsonx.Doc{}
15321538
for cursor.Next(context.Background()) {
15331539
doc = doc[:0]
1534-
err := cursor.Decode(&doc)
1540+
err := cursor.Decode(doc)
15351541
require.NoError(t, err)
15361542

15371543
uom, err := doc.LookupErr("size", "uom")
@@ -1588,7 +1594,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
15881594
doc := bsonx.Doc{}
15891595
for cursor.Next(context.Background()) {
15901596
doc = doc[:0]
1591-
err := cursor.Decode(&doc)
1597+
err := cursor.Decode(doc)
15921598
require.NoError(t, err)
15931599

15941600
uom, err := doc.LookupErr("size", "uom")
@@ -1645,7 +1651,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
16451651
doc := bsonx.Doc{}
16461652
for cursor.Next(context.Background()) {
16471653
doc = doc[:0]
1648-
err := cursor.Decode(&doc)
1654+
err := cursor.Decode(doc)
16491655
require.NoError(t, err)
16501656

16511657
require.True(t, containsKey(doc, "_id"))
@@ -1663,7 +1669,6 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
16631669

16641670
}
16651671

1666-
// DeleteExamples contains examples of delete operations.
16671672
func DeleteExamples(t *testing.T, db *mongo.Database) {
16681673
err := db.RunCommand(
16691674
context.Background(),

0 commit comments

Comments
 (0)