-
Notifications
You must be signed in to change notification settings - Fork 3
/
context_test.go
122 lines (95 loc) · 2.44 KB
/
context_test.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package bond
import (
"context"
"io"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
)
type MockBatch struct {
mock.Mock
}
func (m *MockBatch) ID() uint64 {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Type() BatchType {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Len() int {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Empty() bool {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Reset() {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) ResetRetained() {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Get(key []byte, batch ...Batch) (data []byte, closer io.Closer, err error) {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Set(key []byte, value []byte, opt WriteOptions, batch ...Batch) error {
args := m.Called(key, value, opt, batch)
return args.Error(0)
}
func (m *MockBatch) Delete(key []byte, opt WriteOptions, batch ...Batch) error {
args := m.Called(key, opt, batch)
return args.Error(0)
}
func (m *MockBatch) DeleteRange(start []byte, end []byte, opt WriteOptions, batch ...Batch) error {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Iter(opt *IterOptions, batch ...Batch) Iterator {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Apply(b Batch, opt WriteOptions) error {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Commit(opt WriteOptions) error {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) Close() error {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) OnCommit(f func(b Batch) error) {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) OnCommitted(f func(b Batch)) {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) OnError(f func(b Batch, err error)) {
//TODO implement me
panic("implement me")
}
func (m *MockBatch) OnClose(f func(b Batch)) {
//TODO implement me
panic("implement me")
}
func TestContextWithBatch(t *testing.T) {
mBatch := &MockBatch{}
bCtx := ContextWithBatch(context.Background(), mBatch)
batchFromCtx := ContextRetrieveBatch(bCtx)
assert.Equal(t, mBatch, batchFromCtx)
}
func TestContextWithSyncBatch(t *testing.T) {
batch := NewSyncBatch(&MockBatch{})
bCtx := ContextWithSyncBatch(context.Background(), batch)
batchFromCtx := ContextRetrieveSyncBatch(bCtx)
assert.Equal(t, batch, batchFromCtx)
}