File: cursor_test.go

package info (click to toggle)
golang-gopkg-rethinkdb-rethinkdb-go.v6 6.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,736 kB
  • sloc: python: 1,382; makefile: 16; sh: 9
file content (34 lines) | stat: -rw-r--r-- 688 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package rethinkdb

import (
	test "gopkg.in/check.v1"
	"gopkg.in/rethinkdb/rethinkdb-go.v6/internal/integration/tests"
)

type CursorSuite struct{}

var _ = test.Suite(&CursorSuite{})

func (s *CursorSuite) TestCursor_One_Ok(c *test.C) {
	data := map[string]interface{}{
		"A": 1,
		"B": true,
	}

	mock := NewMock()
	ch := make(chan []interface{})
	mock.On(DB("test").Table("test")).Return(ch, nil)
	go func() {
		ch <- []interface{}{data}
		close(ch)
	}()
	res, err := DB("test").Table("test").Run(mock)
	c.Assert(err, test.IsNil)

	var response interface{}
	err = res.One(&response)

	c.Assert(err, test.IsNil)
	c.Assert(response, tests.JsonEquals, data)
	mock.AssertExpectations(c)
}