Skip to content

Commit

Permalink
Another test for the prior NewIter change.
Browse files Browse the repository at this point in the history
  • Loading branch information
niemeyer committed Jan 21, 2015
1 parent 70863c4 commit fce0aed
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3531,6 +3531,27 @@ func (s *S) TestNewIterNoServer(c *C) {
c.Assert(iter.Err(), ErrorMatches, "server not available")
}

func (s *S) TestNewIterNoServerPresetErr(c *C) {
session, err := mgo.Dial("localhost:40001")
c.Assert(err, IsNil)
defer session.Close()

data, err := bson.Marshal(bson.M{"a": 1})

coll := session.DB("mydb").C("mycoll")
iter := coll.NewIter(nil, []bson.Raw{{3, data}}, 42, fmt.Errorf("my error"))

var result struct{ A int }
ok := iter.Next(&result)
c.Assert(ok, Equals, true)
c.Assert(result.A, Equals, 1)

ok = iter.Next(&result)
c.Assert(ok, Equals, false)

c.Assert(iter.Err(), ErrorMatches, "my error")
}

// --------------------------------------------------------------------------
// Some benchmarks that require a running database.

Expand Down

0 comments on commit fce0aed

Please sign in to comment.