|
@@ -51,7 +51,7 @@ func TestSingleNode(t *testing.T) {
|
|
|
// Add a test-and-set test
|
|
// Add a test-and-set test
|
|
|
|
|
|
|
|
// First, we'll test we can change the value if we get it write
|
|
// First, we'll test we can change the value if we get it write
|
|
|
- result, match, err := c.TestAndSet("foo", "bar", "foobar", 100)
|
|
|
|
|
|
|
+ result, match, err := c.CompareAndSwap("foo", "foobar", 100, "foo", 0)
|
|
|
|
|
|
|
|
if err != nil || result.Key != "/foo" || result.Value != "foobar" || result.PrevValue != "bar" || result.TTL != 100 || !match {
|
|
if err != nil || result.Key != "/foo" || result.Value != "foobar" || result.PrevValue != "bar" || result.TTL != 100 || !match {
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -61,16 +61,9 @@ func TestSingleNode(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Next, we'll make sure we can't set it without the correct prior value
|
|
// Next, we'll make sure we can't set it without the correct prior value
|
|
|
- _, _, err = c.TestAndSet("foo", "bar", "foofoo", 100)
|
|
|
|
|
|
|
+ _, _, err = c.CompareAndSwap("foo", "foofoo", 100, "bar", 0)
|
|
|
|
|
|
|
|
if err == nil {
|
|
if err == nil {
|
|
|
t.Fatalf("Set 4 expecting error when setting key with incorrect previous value")
|
|
t.Fatalf("Set 4 expecting error when setting key with incorrect previous value")
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // Finally, we'll make sure a blank previous value still counts as a test-and-set and still has to match
|
|
|
|
|
- _, _, err = c.TestAndSet("foo", "", "barbar", 100)
|
|
|
|
|
-
|
|
|
|
|
- if err == nil {
|
|
|
|
|
- t.Fatalf("Set 5 expecting error when setting key with blank (incorrect) previous value")
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|