diff --git a/.gitmodules b/.gitmodules index 210b35240..a183fc28f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,3 +2,7 @@ path = tests/mongo-go-driver url = https://github.com/mongodb/mongo-go-driver.git branch = master +[submodule "mongoose"] + path = tests/mongoose + url = https://github.com/Automattic/mongoose.git + branch = master diff --git a/tests/.mocharc.json b/tests/.mocharc.json new file mode 100644 index 000000000..bfbd9b3ed --- /dev/null +++ b/tests/.mocharc.json @@ -0,0 +1,3 @@ +{ + "reporter": "json-stream" +} diff --git a/tests/ferret.yml b/tests/ferret.yml index f003f1e50..580ad5da3 100644 --- a/tests/ferret.yml +++ b/tests/ferret.yml @@ -5,7 +5,7 @@ results: common: stats: expected_skip: 1 - expected_pass: 27 + expected_pass: 30 skip: - github.com/FerretDB/dance/tests/ferret/TestCore/InsertMany # https://github.com/FerretDB/FerretDB/issues/200 diff --git a/tests/ferret/core_test.go b/tests/ferret/core_test.go index 6852ca7dc..0f3d52375 100644 --- a/tests/ferret/core_test.go +++ b/tests/ferret/core_test.go @@ -102,6 +102,23 @@ func TestCore(t *testing.T) { "array": primitive.A{"array", int32(42)}, "array-empty": primitive.A{}, + "array-embedded": primitive.A{ + primitive.D{ + primitive.E{Key: "score", Value: 42.13}, + primitive.E{Key: "age", Value: int32(1000)}, + primitive.E{Key: "document", Value: "abc"}, + }, + primitive.D{ + primitive.E{Key: "document", Value: "def"}, + primitive.E{Key: "score", Value: 42.13}, + primitive.E{Key: "age", Value: int32(1000)}, + }, + primitive.D{ + primitive.E{Key: "score", Value: int32(24)}, + primitive.E{Key: "age", Value: int32(1002)}, + primitive.E{Key: "document", Value: "jkl"}, + }, + }, "binary": primitive.Binary{Subtype: 0x80, Data: []byte{42, 0, 13}}, "binary-empty": primitive.Binary{}, @@ -217,6 +234,36 @@ func TestCore(t *testing.T) { // documents // TODO + // $elemMatch + { + name: "elemMatchGtScalar", + q: bson.D{{"value", bson.M{ + "$elemMatch": bson.M{ + "age": bson.D{{"$gt", int32(999)}}, + "score": int32(24), + }, + }}}, + IDs: []string{"array-embedded"}, + }, + { + name: "elemMatchLtScalarEmpty", + q: bson.D{{"value", bson.M{ + "$elemMatch": bson.M{ + "age": bson.D{{"$lt", int32(999)}}, + "score": int32(24), + }, + }}}, + IDs: []string{}, + }, + { + name: "elemMatchScalar", + q: bson.D{{"value", bson.M{ + "$elemMatch": bson.M{ + "score": int32(24), + }, + }}}, + IDs: []string{"array-embedded"}, + }, // arrays // $size { diff --git a/tests/mongoose b/tests/mongoose new file mode 160000 index 000000000..3c7ae7a37 --- /dev/null +++ b/tests/mongoose @@ -0,0 +1 @@ +Subproject commit 3c7ae7a37aa5f663f080e624d2074f636d709f81