File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -417,26 +417,26 @@ Here is an example that shows how to mock a query that returns multiple rows and
417417
418418``` go
419419func TestSomething (t *testing .T ) {
420- mock := r.NewMock ()
421- mock.on (r.Table (" people" )).Return ([]interface {}{
422- map [string ]interface {}{" id" : 1 , " name" : " John Smith" },
423- map [string ]interface {}{" id" : 2 , " name" : " Jane Smith" },
424- }, nil )
425-
426- cursor , err := r.Table (" people" ).Run (mock)
427- if err != nil {
428- t.Errorf (err)
429- }
420+ mock := r.NewMock ()
421+ mock.On (r.Table (" people" )).Return ([]interface {}{
422+ map [string ]interface {}{" id" : 1 , " name" : " John Smith" },
423+ map [string ]interface {}{" id" : 2 , " name" : " Jane Smith" },
424+ }, nil )
430425
431- var rows []interface {}
432- err := res.All (&rows)
433- if err != nil {
434- t.Errorf (err)
435- }
426+ cursor , err := r.Table (" people" ).Run (mock)
427+ if err != nil {
428+ t.Errorf (" err is: %v " , err)
429+ }
430+
431+ var rows []interface {}
432+ err = cursor.All (&rows)
433+ if err != nil {
434+ t.Errorf (" err is: %v " , err)
435+ }
436436
437- // Test result of rows
437+ // Test result of rows
438438
439- mock.AssertExpectations (t)
439+ mock.AssertExpectations (t)
440440}
441441```
442442
You can’t perform that action at this time.
0 commit comments