| 321 | } |
| 322 | |
| 323 | func TestMemcachedClient_Delete(t *testing.T) { |
| 324 | client, _, err := setupDefaultMemcachedClient() |
| 325 | require.NoError(t, err) |
| 326 | |
| 327 | key := "foo" |
| 328 | value := []byte("bar") |
| 329 | expiration := 10 * time.Second |
| 330 | |
| 331 | client.SetAsync(key, value, expiration) |
| 332 | require.NoError(t, client.wait()) |
| 333 | |
| 334 | // Verify that the key is initially present |
| 335 | initialResult := client.GetMulti(context.Background(), []string{key}) |
| 336 | require.Equal(t, map[string][]byte{key: value}, initialResult) |
| 337 | |
| 338 | // Delete operation |
| 339 | err = client.Delete(context.Background(), key) |
| 340 | require.NoError(t, err) |
| 341 | |
| 342 | // Verify that the key is no longer present after deletion |
| 343 | afterDeletionResult := client.GetMulti(context.Background(), []string{key}) |
| 344 | require.Empty(t, afterDeletionResult) |
| 345 | } |
| 346 | |
| 347 | func TestMemcachedClient_Name(t *testing.T) { |
| 348 | client, _, err := setupDefaultMemcachedClient() |