Skip to content

Commit

Permalink
Remove unified test for UpdateMany.
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Sep 10, 2024
1 parent 47e73f5 commit 7368ae2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 214 deletions.
2 changes: 1 addition & 1 deletion internal/test/compilecheck/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ require (
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
4 changes: 2 additions & 2 deletions internal/test/compilecheck/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
11 changes: 11 additions & 0 deletions mongo/integration/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,17 @@ func TestCollection(t *testing.T) {
assert.Equal(mt, int64(0), res.ModifiedCount, "expected modified count 0, got %v", res.ModifiedCount)
assert.NotNil(mt, res.UpsertedID, "expected upserted ID, got nil")
})
// Require 8.0 servers for sort support.
mt.RunOpts("error with sort", mtest.NewOptions().MinServerVersion("8.0"), func(mt *mtest.T) {
filter := bson.D{{"x", bson.D{{"$gte", 3}}}}
update := bson.D{{"$inc", bson.D{{"x", 1}}}}

_, err := mt.Coll.UpdateMany(context.Background(),
filter, update,
&options.UpdateOptions{Sort: bson.D{{"_id", -1}}},
)
assert.EqualError(t, err, "Cannot specify sort with multi=true", "expected an error on UpdateMany with sort")
})
mt.Run("write error", func(mt *mtest.T) {
filter := bson.D{{"_id", "foo"}}
update := bson.D{{"$set", bson.D{{"_id", 3.14159}}}}
Expand Down
23 changes: 0 additions & 23 deletions mongo/integration/crud_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ func createHint(mt *mtest.T, val bson.RawValue) interface{} {
return hint
}

// create a sort document from a bson.RawValue
func createSort(mt *mtest.T, val bson.RawValue) interface{} {
mt.Helper()

var sort interface{}
switch val.Type {
case bsontype.EmbeddedDocument:
sort = val.Document()
default:
mt.Fatalf("unrecognized sort value type: %s\n", val.Type)
}
return sort
}

// returns true if err is a mongo.CommandError containing a code that is expected from a killAllSessions command.
func isExpectedKillAllSessionsError(err error) bool {
cmdErr, ok := err.(mongo.CommandError)
Expand Down Expand Up @@ -904,8 +890,6 @@ func executeUpdateOne(mt *mtest.T, sess mongo.Session, args bson.Raw) (*mongo.Up
opts = opts.SetCollation(createCollation(mt, val.Document()))
case "hint":
opts = opts.SetHint(createHint(mt, val))
case "sort":
opts = opts.SetSort(createSort(mt, val))
case "session":
default:
mt.Fatalf("unrecognized updateOne option: %v", key)
Expand Down Expand Up @@ -954,8 +938,6 @@ func executeUpdateMany(mt *mtest.T, sess mongo.Session, args bson.Raw) (*mongo.U
opts = opts.SetCollation(createCollation(mt, val.Document()))
case "hint":
opts = opts.SetHint(createHint(mt, val))
case "sort":
opts = opts.SetSort(createSort(mt, val))
case "session":
default:
mt.Fatalf("unrecognized updateMany option: %v", key)
Expand Down Expand Up @@ -1000,8 +982,6 @@ func executeReplaceOne(mt *mtest.T, sess mongo.Session, args bson.Raw) (*mongo.U
opts = opts.SetCollation(createCollation(mt, val.Document()))
case "hint":
opts = opts.SetHint(createHint(mt, val))
case "sort":
opts = opts.SetSort(createSort(mt, val))
case "session":
default:
mt.Fatalf("unrecognized replaceOne option: %v", key)
Expand Down Expand Up @@ -1142,9 +1122,6 @@ func createBulkWriteModel(mt *mtest.T, rawModel bson.Raw) mongo.WriteModel {
if hintVal, err := args.LookupErr("hint"); err == nil {
uom.SetHint(createHint(mt, hintVal))
}
if sortVal, err := args.LookupErr("sort"); err == nil {
uom.SetSort(createSort(mt, sortVal))
}
if uom.Upsert == nil {
uom.SetUpsert(false)
}
Expand Down
132 changes: 0 additions & 132 deletions testdata/crud/unified/updateMany-sort.json

This file was deleted.

56 changes: 0 additions & 56 deletions testdata/crud/unified/updateMany-sort.yml

This file was deleted.

0 comments on commit 7368ae2

Please sign in to comment.