| 245 | } |
| 246 | |
| 247 | func TestStringExist(t *testing.T) { |
| 248 | setValue(t, TestExistKey, value) |
| 249 | // write exist string |
| 250 | tests := []struct { |
| 251 | name string |
| 252 | key []byte |
| 253 | want bool |
| 254 | }{ |
| 255 | { |
| 256 | name: "Exist", |
| 257 | key: TestExistKey, |
| 258 | want: true, |
| 259 | }, |
| 260 | { |
| 261 | name: "NoExist", |
| 262 | key: TestNoExistKey, |
| 263 | want: false, |
| 264 | }, |
| 265 | } |
| 266 | for _, tt := range tests { |
| 267 | t.Run(tt.name, func(t *testing.T) { |
| 268 | callFunc := func(txn *Transaction) { |
| 269 | s, err := GetString(txn, tt.key) |
| 270 | assert.NoError(t, err) |
| 271 | got := s.Exist() |
| 272 | assert.Equal(t, tt.want, got) |
| 273 | } |
| 274 | MockTest(t, callFunc) |
| 275 | }) |
| 276 | } |
| 277 | |
| 278 | } |
| 279 | |
| 280 | func TestStringAppend(t *testing.T) { |
| 281 | setValue(t, TestExistKey, value) |