Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaomei authored and zhaomei committed Jun 7, 2018
1 parent ffd2e49 commit 634e6bc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,7 @@ func (s *S) TestFindAndModifyWriteConcern(c *C) {
defer session.Close()

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

// Tweak the safety parameters to something unachievable.
Expand All @@ -1391,15 +1391,14 @@ func (s *S) TestFindAndModifyWriteConcern(c *C) {
ReturnNew: false,
}
info, err := coll.Find(M{"id": M{"$exists": true}}).Apply(change, &ret)
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves|Not enough data-bearing nodes|waiting for replication timed out")
if !s.versionAtLeast(2, 6) {
// 2.6 turned it into a query error.
c.Assert(err.(*mgo.LastError).WTimeout, Equals, true)
}
c.Assert(info.Updated, Equals, 1)
c.Assert(info.Matched, Equals, 1)
c.Assert(info.UpsertedId, NotNil)
c.Assert(ret.Id, Equals, 50)
c.Assert(ret.Id, Equals, 42)

if s.versionAtLeast(3, 2) {
// findAndModify support writeConcern after version 3.2.
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves|Not enough data-bearing nodes|waiting for replication timed out")
}
}

func (s *S) TestFindAndModifyBug997828(c *C) {
Expand Down

0 comments on commit 634e6bc

Please sign in to comment.