| 319 | } |
| 320 | |
| 321 | func TestStringGetSet(t *testing.T) { |
| 322 | setValue(t, []byte("GetSetExistKey"), value) |
| 323 | type args struct { |
| 324 | value []byte |
| 325 | } |
| 326 | tests := []struct { |
| 327 | name string |
| 328 | args args |
| 329 | key []byte |
| 330 | want []byte |
| 331 | }{ |
| 332 | { |
| 333 | name: "GetSet_ExistKey", |
| 334 | args: args{ |
| 335 | value: []byte("NewVlaue"), |
| 336 | }, |
| 337 | key: []byte("GetSetExistKey"), |
| 338 | want: value, |
| 339 | }, |
| 340 | { |
| 341 | name: "GetSet_NoExistKey", |
| 342 | args: args{ |
| 343 | value: []byte("NewVlaue"), |
| 344 | }, |
| 345 | key: []byte("GetSetNoExistKey"), |
| 346 | want: nil, |
| 347 | }, |
| 348 | } |
| 349 | for _, tt := range tests { |
| 350 | t.Run(tt.name, func(t *testing.T) { |
| 351 | callFunc := func(txn *Transaction) { |
| 352 | s, err := GetString(txn, tt.key) |
| 353 | assert.NoError(t, err) |
| 354 | got, err := s.GetSet(tt.args.value) |
| 355 | assert.NoError(t, err) |
| 356 | assert.Equal(t, tt.want, got) |
| 357 | value, err := s.Get() |
| 358 | assert.NoError(t, err) |
| 359 | assert.Equal(t, value, []byte("NewVlaue")) |
| 360 | } |
| 361 | MockTest(t, callFunc) |
| 362 | }) |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | func TestStringGetRange(t *testing.T) { |
| 367 | type args struct { |