(t *testing.T)
| 327 | |
| 328 | } |
| 329 | func TestBoltDbStore_GetUint64(t *testing.T) { |
| 330 | type kv struct { |
| 331 | key string |
| 332 | val uint64 |
| 333 | } |
| 334 | type test struct { |
| 335 | name string |
| 336 | input []kv |
| 337 | query []kv |
| 338 | expectError bool |
| 339 | } |
| 340 | tests := []test{ |
| 341 | { |
| 342 | name: "set three", |
| 343 | input: []kv{ |
| 344 | {key: "1", val: 11}, |
| 345 | {key: "foo", val: 55}, |
| 346 | {key: "hello", val: 336}, |
| 347 | }, |
| 348 | query: []kv{ |
| 349 | {key: "1", val: 11}, |
| 350 | {key: "foo", val: 55}, |
| 351 | {key: "hello", val: 336}, |
| 352 | }, |
| 353 | expectError: false, |
| 354 | }, |
| 355 | { |
| 356 | name: "non existence", |
| 357 | input: []kv{ |
| 358 | {key: "4", val: 2}, |
| 359 | }, |
| 360 | query: []kv{ |
| 361 | {key: "1", val: 2}, |
| 362 | {key: "2", val: 4}, |
| 363 | }, |
| 364 | expectError: true, |
| 365 | }, |
| 366 | } |
| 367 | for _, tc := range tests { |
| 368 | ds, err := testBoltDatastore() |
| 369 | assert.NoError(t, err) |
| 370 | // set all inputs |
| 371 | for _, v := range tc.input { |
| 372 | _ = ds.Set(stringToBytes(v.key), uint64ToBytes(v.val)) |
| 373 | |
| 374 | } |
| 375 | // recall all inputs |
| 376 | for _, v := range tc.query { |
| 377 | val, err := ds.Get(stringToBytes(v.key)) |
| 378 | if tc.expectError { |
| 379 | assert.NotNil(t, err) |
| 380 | } else { |
| 381 | assert.NoError(t, err) |
| 382 | assert.Equal(t, v.val, bytesToUint64(val)) |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | } |
nothing calls this directly
no test coverage detected