MCPcopy Create free account
hub / github.com/ByteStorage/FlyDB / TestBoltDbStore_Set

Function TestBoltDbStore_Set

lib/datastore/boltdb_test.go:168–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

166}
167
168func TestBoltDbStore_Set(t *testing.T) {
169 ds, err := testBoltDatastore()
170 assert.NoError(t, err)
171 type kv struct {
172 key string
173 val string
174 }
175 type test struct {
176 input []kv
177 expectError bool
178 }
179 tests := []test{
180 {
181 input: []kv{
182 {key: "1", val: "2"},
183 {key: "foo", val: "bar"},
184 {key: "hello", val: "world"},
185 },
186 expectError: false,
187 },
188 {
189 input: []kv{
190 {key: "", val: "bar"},
191 },
192 expectError: true,
193 },
194 }
195 for _, tc := range tests {
196 // set all inputs
197 for _, v := range tc.input {
198 err := ds.Set(stringToBytes(v.key), stringToBytes(v.val))
199 if tc.expectError {
200 assert.NotNil(t, err)
201 } else {
202 assert.NoError(t, err)
203 }
204 }
205 // recall all inputs
206 for _, v := range tc.input {
207 val, err := ds.Get(stringToBytes(v.key))
208 if tc.expectError {
209 assert.NotNil(t, err)
210 } else {
211 assert.NoError(t, err)
212 assert.Equal(t, v.val, string(val))
213 }
214 }
215
216 }
217
218}
219func TestBoltDbStore_Get(t *testing.T) {
220 type kv struct {
221 key string

Callers

nothing calls this directly

Calls 4

testBoltDatastoreFunction · 0.85
stringToBytesFunction · 0.85
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected