forked from willfaught/gockle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterator.go
61 lines (48 loc) · 1.27 KB
/
iterator.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package gockle
import (
"github.com/gocql/gocql"
"github.com/maraino/go-mock"
)
// Iterator iterates CQL query result rows.
type Iterator interface {
// Close closes the Iterator.
Close() error
// Scan puts the current result row in results and returns whether there are
// more result rows.
Scan(results ...interface{}) bool
// ScanMap puts the current result row in results and returns whether there are
// more result rows.
ScanMap(results map[string]interface{}) bool
}
var (
_ Iterator = IteratorMock{}
_ Iterator = iterator{}
)
// IteratorMock is a mock Iterator. See github.com/maraino/go-mock.
type IteratorMock struct {
mock.Mock
}
// Close implements Iterator.
func (m IteratorMock) Close() error {
return m.Called().Error(0)
}
// Scan implements Iterator.
func (m IteratorMock) Scan(results ...interface{}) bool {
return m.Called(results).Bool(0)
}
// ScanMap implements Iterator.
func (m IteratorMock) ScanMap(results map[string]interface{}) bool {
return m.Called(results).Bool(0)
}
type iterator struct {
i *gocql.Iter
}
func (i iterator) Close() error {
return i.i.Close()
}
func (i iterator) Scan(results ...interface{}) bool {
return i.i.Scan(results...)
}
func (i iterator) ScanMap(results map[string]interface{}) bool {
return i.i.MapScan(results)
}