@@ -1001,6 +1001,26 @@ func (s *S) TestIsDupFindAndModify(c *C) {
10011001 c .Assert (mgo .IsDup (err ), Equals , true )
10021002}
10031003
1004+ func (s * S ) TestIsDupRetryUpsert (c * C ) {
1005+ session , err := mgo .Dial ("localhost:40001" )
1006+ c .Assert (err , IsNil )
1007+ defer session .Close ()
1008+
1009+ coll := session .DB ("mydb" ).C ("mycoll" )
1010+
1011+ err = coll .Insert (bson.M {"_id" : 1 , "x" : 1 })
1012+ c .Assert (err , IsNil )
1013+
1014+ _ , err = coll .Upsert (bson.M {"_id" : 1 , "x" : 2 }, bson.M {"$set" : bson.M {"x" : 3 }})
1015+ c .Assert (mgo .IsDup (err ), Equals , true )
1016+
1017+ _ , err = coll .Find (bson.M {"_id" : 1 , "x" : 2 }).Apply (mgo.Change {
1018+ Update : bson.M {"$set" : bson.M {"x" : 3 }},
1019+ Upsert : true ,
1020+ }, nil )
1021+ c .Assert (mgo .IsDup (err ), Equals , true )
1022+ }
1023+
10041024func (s * S ) TestFindAndModify (c * C ) {
10051025 session , err := mgo .Dial ("localhost:40011" )
10061026 c .Assert (err , IsNil )
@@ -4159,11 +4179,11 @@ func (s *S) TestBypassValidation(c *C) {
41594179
41604180func (s * S ) TestVersionAtLeast (c * C ) {
41614181 tests := [][][]int {
4162- {{3 ,2 , 1 }, {3 ,2 , 0 }},
4163- {{3 ,2 , 1 }, {3 ,2 }},
4164- {{3 ,2 , 1 }, {2 ,5 , 5 , 5 }},
4165- {{3 ,2 , 1 }, {2 ,5 , 5 }},
4166- {{3 ,2 , 1 }, {2 ,5 }},
4182+ {{3 , 2 , 1 }, {3 , 2 , 0 }},
4183+ {{3 , 2 , 1 }, {3 , 2 }},
4184+ {{3 , 2 , 1 }, {2 , 5 , 5 , 5 }},
4185+ {{3 , 2 , 1 }, {2 , 5 , 5 }},
4186+ {{3 , 2 , 1 }, {2 , 5 }},
41674187 }
41684188 for _ , pair := range tests {
41694189 bi := mgo.BuildInfo {VersionArray : pair [0 ]}
0 commit comments