From e431ec26a8a1cf1521b7e4fb71b92d4677fd0483 Mon Sep 17 00:00:00 2001 From: zhaomei Date: Thu, 7 Jun 2018 20:16:09 +0800 Subject: [PATCH] fix unit test --- session_test.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/session_test.go b/session_test.go index dc85f5133..f3ac2da92 100644 --- a/session_test.go +++ b/session_test.go @@ -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. @@ -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, uint64(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) {