1package internal
2
3import "github.com/influxdata/influxdb/tsdb"
4
5var (
6	_ tsdb.IntegerBatchCursor  = NewIntegerBatchCursorMock()
7	_ tsdb.FloatBatchCursor    = NewFloatBatchCursorMock()
8	_ tsdb.UnsignedBatchCursor = NewUnsignedBatchCursorMock()
9	_ tsdb.StringBatchCursor   = NewStringBatchCursorMock()
10	_ tsdb.BooleanBatchCursor  = NewBooleanBatchCursorMock()
11)
12
13// BatchCursorMock provides a mock base implementation for batch cursors.
14type BatchCursorMock struct {
15	CloseFn func()
16	ErrFn   func() error
17}
18
19// NewBatchCursorMock returns an initialised BatchCursorMock, which
20// returns the zero value for all methods.
21func NewBatchCursorMock() *BatchCursorMock {
22	return &BatchCursorMock{
23		CloseFn: func() {},
24		ErrFn:   func() error { return nil },
25	}
26}
27
28// Close closes the cursor.
29func (c *BatchCursorMock) Close() { c.CloseFn() }
30
31// Err returns the latest error, if any.
32func (c *BatchCursorMock) Err() error { return c.ErrFn() }
33
34// IntegerBatchCursorMock provides a mock implementation of an IntegerBatchCursorMock.
35type IntegerBatchCursorMock struct {
36	*BatchCursorMock
37	NextFn func() (keys []int64, values []int64)
38}
39
40// NewIntegerBatchCursorMock returns an initialised IntegerBatchCursorMock, which
41// returns the zero value for all methods.
42func NewIntegerBatchCursorMock() *IntegerBatchCursorMock {
43	return &IntegerBatchCursorMock{
44		BatchCursorMock: NewBatchCursorMock(),
45		NextFn:          func() ([]int64, []int64) { return nil, nil },
46	}
47}
48
49// Next returns the next set of keys and values.
50func (c *IntegerBatchCursorMock) Next() (keys []int64, values []int64) {
51	return c.NextFn()
52}
53
54// FloatBatchCursorMock provides a mock implementation of a FloatBatchCursor.
55type FloatBatchCursorMock struct {
56	*BatchCursorMock
57	NextFn func() (keys []int64, values []float64)
58}
59
60// NewFloatBatchCursorMock returns an initialised FloatBatchCursorMock, which
61// returns the zero value for all methods.
62func NewFloatBatchCursorMock() *FloatBatchCursorMock {
63	return &FloatBatchCursorMock{
64		BatchCursorMock: NewBatchCursorMock(),
65		NextFn:          func() ([]int64, []float64) { return nil, nil },
66	}
67}
68
69// Next returns the next set of keys and values.
70func (c *FloatBatchCursorMock) Next() (keys []int64, values []float64) {
71	return c.NextFn()
72}
73
74// UnsignedBatchCursorMock provides a mock implementation of an UnsignedBatchCursorMock.
75type UnsignedBatchCursorMock struct {
76	*BatchCursorMock
77	NextFn func() (keys []int64, values []uint64)
78}
79
80// NewUnsignedBatchCursorMock returns an initialised UnsignedBatchCursorMock, which
81// returns the zero value for all methods.
82func NewUnsignedBatchCursorMock() *UnsignedBatchCursorMock {
83	return &UnsignedBatchCursorMock{
84		BatchCursorMock: NewBatchCursorMock(),
85		NextFn:          func() ([]int64, []uint64) { return nil, nil },
86	}
87}
88
89// Next returns the next set of keys and values.
90func (c *UnsignedBatchCursorMock) Next() (keys []int64, values []uint64) {
91	return c.NextFn()
92}
93
94// StringBatchCursorMock provides a mock implementation of a StringBatchCursor.
95type StringBatchCursorMock struct {
96	*BatchCursorMock
97	NextFn func() (keys []int64, values []string)
98}
99
100// NewStringBatchCursorMock returns an initialised StringBatchCursorMock, which
101// returns the zero value for all methods.
102func NewStringBatchCursorMock() *StringBatchCursorMock {
103	return &StringBatchCursorMock{
104		BatchCursorMock: NewBatchCursorMock(),
105		NextFn:          func() ([]int64, []string) { return nil, nil },
106	}
107}
108
109// Next returns the next set of keys and values.
110func (c *StringBatchCursorMock) Next() (keys []int64, values []string) {
111	return c.NextFn()
112}
113
114// BooleanBatchCursorMock provides a mock implementation of a BooleanBatchCursor.
115type BooleanBatchCursorMock struct {
116	*BatchCursorMock
117	NextFn func() (keys []int64, values []bool)
118}
119
120// NewBooleanBatchCursorMock returns an initialised BooleanBatchCursorMock, which
121// returns the zero value for all methods.
122func NewBooleanBatchCursorMock() *BooleanBatchCursorMock {
123	return &BooleanBatchCursorMock{
124		BatchCursorMock: NewBatchCursorMock(),
125		NextFn:          func() ([]int64, []bool) { return nil, nil },
126	}
127}
128
129// Next returns the next set of keys and values.
130func (c *BooleanBatchCursorMock) Next() (keys []int64, values []bool) {
131	return c.NextFn()
132}
133