TestNilCAS ensures we can return nil from the CAS callback when we don't want to modify the value.
(t *testing.T)
| 76 | // TestNilCAS ensures we can return nil from the CAS callback when we don't |
| 77 | // want to modify the value. |
| 78 | func TestNilCAS(t *testing.T) { |
| 79 | withFixtures(t, func(t *testing.T, client Client) { |
| 80 | // Blindly set key to "0". |
| 81 | err := client.CAS(ctx, key, func(interface{}) (interface{}, bool, error) { |
| 82 | return "0", true, nil |
| 83 | }) |
| 84 | require.NoError(t, err) |
| 85 | |
| 86 | // Ensure key is "0" and don't set it. |
| 87 | err = client.CAS(ctx, key, func(in interface{}) (interface{}, bool, error) { |
| 88 | require.EqualValues(t, "0", in) |
| 89 | return nil, false, nil |
| 90 | }) |
| 91 | require.NoError(t, err) |
| 92 | |
| 93 | // Make sure value is still 0. |
| 94 | value, err := client.Get(ctx, key) |
| 95 | require.NoError(t, err) |
| 96 | require.EqualValues(t, "0", value) |
| 97 | }) |
| 98 | } |
| 99 | |
| 100 | func TestWatchKey(t *testing.T) { |
| 101 | const key = "test" |
nothing calls this directly
no test coverage detected