@@ -1001,6 +1001,26 @@ func (s *S) TestIsDupFindAndModify(c *C) {
1001
1001
c .Assert (mgo .IsDup (err ), Equals , true )
1002
1002
}
1003
1003
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
+
1004
1024
func (s * S ) TestFindAndModify (c * C ) {
1005
1025
session , err := mgo .Dial ("localhost:40011" )
1006
1026
c .Assert (err , IsNil )
@@ -4159,11 +4179,11 @@ func (s *S) TestBypassValidation(c *C) {
4159
4179
4160
4180
func (s * S ) TestVersionAtLeast (c * C ) {
4161
4181
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 }},
4167
4187
}
4168
4188
for _ , pair := range tests {
4169
4189
bi := mgo.BuildInfo {VersionArray : pair [0 ]}
0 commit comments