Skip to content

Commit

Permalink
Revert "Update Makefile to run examples and fix bugs in examples."
Browse files Browse the repository at this point in the history
This reverts commit 0cb0bd0.

Reason for revert: Failing tests on Evergreen.

Change-Id: I60063242fea97c603ed02e565493101e1afa38b3
  • Loading branch information
skriptble committed Jan 31, 2019
1 parent 0f35742 commit 42e68e3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
1 change: 0 additions & 1 deletion .lint-whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,3 @@ bson/internal/jsonparser/parser.go:1137:9: if block ends with a return statement
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)
bson/internal/jsonparser/parser_test.go:1361:5: var testJson should be testJSON
bson/internal/jsonpretty/pretty.go:7:1: comment on exported type Options should be of the form "Options ..." (with optional leading article)
examples/documentation_examples/examples.go:10:1: don't use an underscore in package name
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ UNSTABLE_PKGS = $(shell etc/list_pkgs.sh ./x)
UNSTABLE_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./x)
TAG_PKG = $(shell etc/list_pkgs.sh ./tag)
TAG_TEST_PKG = $(shell etc/list_test_pkgs.sh ./tag)
EXAMPLES_PKGS = $(shell etc/list_pkgs.sh ./examples)
EXAMPLES_TEST_PKGS = $(shell etc/list_test_pkgs.sh ./examples)
PKGS = $(BSON_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG) $(EXAMPLES_PKGS)
TEST_PKGS = $(BSON_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG) $(EXAMPLES_TEST_PKGS)
PKGS = $(BSON_PKGS) $(MONGO_PKGS) $(UNSTABLE_PKGS) $(TAG_PKG)
TEST_PKGS = $(BSON_TEST_PKGS) $(MONGO_TEST_PKGS) $(UNSTABLE_TEST_PKGS) $(TAG_PKG)

TEST_TIMEOUT = 600

Expand Down
49 changes: 27 additions & 22 deletions examples/documentation_examples/examples.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ func requireCursorLength(t *testing.T, cursor mongo.Cursor, length int) {
require.Equal(t, i, length)
}

func stringSliceEquals(s1 []string, s2 []string) bool {
if len(s1) != len(s2) {
return false
}

for i := range s1 {
if s1[i] != s2[i] {
return false
}
}

return true
}

func containsKey(doc bsonx.Doc, key ...string) bool {
_, err := doc.LookupErr(key...)
if err != nil {
Expand All @@ -39,7 +53,6 @@ func containsKey(doc bsonx.Doc, key ...string) bool {
return true
}

// InsertExamples contains examples for insert operations.
func InsertExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down Expand Up @@ -131,7 +144,6 @@ func InsertExamples(t *testing.T, db *mongo.Database) {
}
}

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

}

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

}

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

}

// QueryArrayEmbeddedDocumentsExamples contains examples for querying fields with arrays and embedded documents.
func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down Expand Up @@ -887,7 +896,6 @@ func QueryArrayEmbeddedDocumentsExamples(t *testing.T, db *mongo.Database) {
}
}

// QueryNullMissingFieldsExamples contains examples for querying fields that are null or missing.
func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down Expand Up @@ -968,7 +976,6 @@ func QueryNullMissingFieldsExamples(t *testing.T, db *mongo.Database) {
}
}

// ProjectionExamples contains examples for specifying projections in find operations.
func ProjectionExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down Expand Up @@ -1108,7 +1115,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

require.True(t, containsKey(doc, "_id"))
Expand Down Expand Up @@ -1145,7 +1152,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

require.False(t, containsKey(doc, "_id"))
Expand Down Expand Up @@ -1181,7 +1188,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

require.True(t, containsKey(doc, "_id"))
Expand Down Expand Up @@ -1218,7 +1225,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

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

require.True(t, containsKey(doc, "size", "uom"))
require.True(t, containsKey(doc, "uom", "size"))
require.False(t, containsKey(doc, "h", "size"))
require.False(t, containsKey(doc, "w", "size"))

Expand Down Expand Up @@ -1258,7 +1265,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

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

require.False(t, containsKey(doc, "uom", "size"))
require.True(t, containsKey(doc, "size", "h"))
require.True(t, containsKey(doc, "size", "w"))
require.True(t, containsKey(doc, "h", "size"))
require.True(t, containsKey(doc, "w", "size"))

}

Expand Down Expand Up @@ -1300,7 +1307,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

require.True(t, containsKey(doc, "_id"))
Expand Down Expand Up @@ -1353,7 +1360,7 @@ func ProjectionExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

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

// UpdateExamples contains examples of update operations.
func UpdateExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down Expand Up @@ -1531,7 +1537,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

uom, err := doc.LookupErr("size", "uom")
Expand Down Expand Up @@ -1588,7 +1594,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

uom, err := doc.LookupErr("size", "uom")
Expand Down Expand Up @@ -1645,7 +1651,7 @@ func UpdateExamples(t *testing.T, db *mongo.Database) {
doc := bsonx.Doc{}
for cursor.Next(context.Background()) {
doc = doc[:0]
err := cursor.Decode(&doc)
err := cursor.Decode(doc)
require.NoError(t, err)

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

}

// DeleteExamples contains examples of delete operations.
func DeleteExamples(t *testing.T, db *mongo.Database) {
err := db.RunCommand(
context.Background(),
Expand Down

0 comments on commit 42e68e3

Please sign in to comment.