@@ -2,7 +2,6 @@ package rethinkdb
22
33import (
44 "fmt"
5-
65 "testing"
76
87 test "gopkg.in/check.v1"
@@ -350,6 +349,54 @@ func (s *MockSuite) TestMockAnything(c *test.C) {
350349 mock .AssertExpectations (c )
351350}
352351
352+ func (s * MockSuite ) TestMockMapSliceResultOk (c * test.C ) {
353+ type Some struct {
354+ Id string
355+ }
356+
357+ result := []map [string ]interface {}{
358+ {"Id" : "test1" },
359+ {"Id" : "test2" },
360+ }
361+
362+ mock := NewMock ()
363+ q := DB ("test" ).Table ("test" ).GetAll ()
364+ mock .On (q ).Return (result , nil )
365+ res , err := q .Run (mock )
366+ c .Assert (err , test .IsNil )
367+
368+ var casted []* Some
369+ err = res .All (& casted )
370+ c .Assert (err , test .IsNil )
371+
372+ c .Assert (casted [0 ].Id , test .Equals , "test1" )
373+ c .Assert (casted [1 ].Id , test .Equals , "test2" )
374+ }
375+
376+ func (s * MockSuite ) TestMockPointerSliceResultOk (c * test.C ) {
377+ type Some struct {
378+ Id string
379+ }
380+
381+ result := []* Some {
382+ {Id : "test1" },
383+ {Id : "test2" },
384+ }
385+
386+ mock := NewMock ()
387+ q := DB ("test" ).Table ("test" ).GetAll ()
388+ mock .On (q ).Return (result , nil )
389+ res , err := q .Run (mock )
390+ c .Assert (err , test .IsNil )
391+
392+ var casted []* Some
393+ err = res .All (& casted )
394+ c .Assert (err , test .IsNil )
395+
396+ c .Assert (casted [0 ].Id , test .Equals , "test1" )
397+ c .Assert (casted [1 ].Id , test .Equals , "test2" )
398+ }
399+
353400func (s * MockSuite ) TestMockRethinkStructsRunWrite (c * test.C ) {
354401 mock := NewMock ()
355402 mock .On (DB ("test" ).Table ("test" ).Update (map [string ]int {"val" : 1 })).Return (WriteResponse {
0 commit comments