Skip to content

Commit 634e6bc

Browse files
zhaomeizhaomei
zhaomei
authored and
zhaomei
committed
fix unit test
1 parent ffd2e49 commit 634e6bc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

session_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ func (s *S) TestFindAndModifyWriteConcern(c *C) {
13761376
defer session.Close()
13771377

13781378
coll := session.DB("mydb").C("mycoll")
1379-
err = coll.Insert(M{"fid": 42})
1379+
err = coll.Insert(M{"id": 42})
13801380
c.Assert(err, IsNil)
13811381

13821382
// Tweak the safety parameters to something unachievable.
@@ -1391,15 +1391,14 @@ func (s *S) TestFindAndModifyWriteConcern(c *C) {
13911391
ReturnNew: false,
13921392
}
13931393
info, err := coll.Find(M{"id": M{"$exists": true}}).Apply(change, &ret)
1394-
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves|Not enough data-bearing nodes|waiting for replication timed out")
1395-
if !s.versionAtLeast(2, 6) {
1396-
// 2.6 turned it into a query error.
1397-
c.Assert(err.(*mgo.LastError).WTimeout, Equals, true)
1398-
}
13991394
c.Assert(info.Updated, Equals, 1)
14001395
c.Assert(info.Matched, Equals, 1)
1401-
c.Assert(info.UpsertedId, NotNil)
1402-
c.Assert(ret.Id, Equals, 50)
1396+
c.Assert(ret.Id, Equals, 42)
1397+
1398+
if s.versionAtLeast(3, 2) {
1399+
// findAndModify support writeConcern after version 3.2.
1400+
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves|Not enough data-bearing nodes|waiting for replication timed out")
1401+
}
14031402
}
14041403

14051404
func (s *S) TestFindAndModifyBug997828(c *C) {

0 commit comments

Comments
 (0)