| 278 | } |
| 279 | |
| 280 | func TestStringAppend(t *testing.T) { |
| 281 | setValue(t, TestExistKey, value) |
| 282 | type args struct { |
| 283 | value []byte |
| 284 | } |
| 285 | tests := []struct { |
| 286 | name string |
| 287 | args args |
| 288 | key []byte |
| 289 | want int |
| 290 | }{ |
| 291 | { |
| 292 | name: "TestString_AppendExistKey", |
| 293 | args: args{ |
| 294 | value: value, |
| 295 | }, |
| 296 | key: TestExistKey, |
| 297 | want: 22, |
| 298 | }, |
| 299 | { |
| 300 | name: "TestString_AppendNoExistKey", |
| 301 | args: args{ |
| 302 | value: value, |
| 303 | }, |
| 304 | key: TestNoExistKey, |
| 305 | want: 11, |
| 306 | }, |
| 307 | } |
| 308 | for _, tt := range tests { |
| 309 | t.Run(tt.name, func(t *testing.T) { |
| 310 | callFunc := func(txn *Transaction) { |
| 311 | s, err := GetString(txn, tt.key) |
| 312 | assert.NoError(t, err) |
| 313 | got, err := s.Append(tt.args.value) |
| 314 | assert.Equal(t, tt.want, got) |
| 315 | } |
| 316 | MockTest(t, callFunc) |
| 317 | }) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | func TestStringGetSet(t *testing.T) { |
| 322 | setValue(t, []byte("GetSetExistKey"), value) |