Hi there. I'd wrote two almost equal tests (preferred location for it is ./mock_test.go):
the first pass and the second fails:
func (s *MockSuite) TestMockMapSliceResultOk(c *test.C) {
type Some struct {
Id string
}
result := []map[string]interface{}{
{"Id": "test1"},
{"Id": "test2"},
}
mock := NewMock()
q := DB("test").Table("test").GetAll()
mock.On(q).Return(result, nil)
res, err := q.Run(mock)
c.Assert(err, test.IsNil)
var casted []*Some
err = res.All(&casted)
c.Assert(err, test.IsNil)
c.Assert(casted[0].Id, test.Equals, "test1")
c.Assert(casted[1].Id, test.Equals, "test2")
}
func (s *MockSuite) TestMockPointerSliceResultOk(c *test.C) {
type Some struct {
Id string
}
result := []*Some{
{Id: "test1"},
{Id: "test2"},
}
mock := NewMock()
q := DB("test").Table("test").GetAll()
mock.On(q).Return(result, nil)
res, err := q.Run(mock)
c.Assert(err, test.IsNil)
var casted []*Some
err = res.All(&casted)
c.Assert(err, test.IsNil)
c.Assert(casted[0].Id, test.Equals, "test1")
c.Assert(casted[1].Id, test.Equals, "test2")
}
Expected :
Actual :encoding.DecodeTypeError = &encoding.DecodeTypeError{DestType:(reflect.rtype)(0x87d280), SrcType:(reflect.rtype)(0x87d280), Reason:""} ("rethinkdb: could not decode type rethinkdb.Some into Go value of type *rethinkdb.Some")
Hi there. I'd wrote two almost equal tests (preferred location for it is ./mock_test.go): the first pass and the second fails: