Skip to content

Commit

Permalink
Trivial test fixes for 2.8.0-rc3.
Browse files Browse the repository at this point in the history
  • Loading branch information
niemeyer committed Dec 21, 2014
1 parent 5463a0a commit 513c45d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,9 +1028,13 @@ func (s *S) TestQueryExplain(c *C) {
query := coll.Find(nil).Limit(2)
err = query.Explain(m)
c.Assert(err, IsNil)
c.Assert(m["cursor"], Equals, "BasicCursor")
c.Assert(m["nscanned"], Equals, 2)
c.Assert(m["n"], Equals, 2)
if m["queryPlanner"] != nil {
c.Assert(m["executionStats"].(M)["totalDocsExamined"], Equals, 2)
} else {
c.Assert(m["cursor"], Equals, "BasicCursor")
c.Assert(m["nscanned"], Equals, 2)
c.Assert(m["n"], Equals, 2)
}

n := 0
var result M
Expand Down Expand Up @@ -1072,8 +1076,16 @@ func (s *S) TestQueryHint(c *C) {
m := M{}
err = coll.Find(nil).Hint("a").Explain(m)
c.Assert(err, IsNil)
c.Assert(m["indexBounds"], NotNil)
c.Assert(m["indexBounds"].(M)["a"], NotNil)

if m["queryPlanner"] != nil {
m = m["queryPlanner"].(M)
m = m["winningPlan"].(M)
m = m["inputStage"].(M)
c.Assert(m["indexName"], Equals, "a_1")
} else {
c.Assert(m["indexBounds"], NotNil)
c.Assert(m["indexBounds"].(M)["a"], NotNil)
}
}

func (s *S) TestFindOneNotFound(c *C) {
Expand Down Expand Up @@ -2401,7 +2413,7 @@ func (s *S) TestSafeParameters(c *C) {
// Tweak the safety parameters to something unachievable.
session.SetSafe(&mgo.Safe{W: 4, WTimeout: 100})
err = coll.Insert(M{"_id": 1})
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves")
c.Assert(err, ErrorMatches, "timeout|timed out waiting for slaves|Not enough data-bearing nodes")
if !s.versionAtLeast(2, 6) {
// 2.6 turned it into a query error.
c.Assert(err.(*mgo.LastError).WTimeout, Equals, true)
Expand Down

0 comments on commit 513c45d

Please sign in to comment.