Skip to content

Commit

Permalink
clientv3/integration: test compare on range
Browse files Browse the repository at this point in the history
  • Loading branch information
heyitsanthony committed Jun 16, 2017
1 parent 7ff6e62 commit 8f34d0c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions clientv3/integration/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,30 @@ func TestTxnSuccess(t *testing.T) {
t.Fatalf("unexpected Get response %v", resp)
}
}

func TestTxnCompareRange(t *testing.T) {
defer testutil.AfterTest(t)

clus := integration.NewClusterV3(t, &integration.ClusterConfig{Size: 1})
defer clus.Terminate(t)

kv := clus.Client(0)
fooResp, err := kv.Put(context.TODO(), "foo/", "bar")
if err != nil {
t.Fatal(err)
}
if _, err = kv.Put(context.TODO(), "foo/a", "baz"); err != nil {
t.Fatal(err)
}
tresp, terr := kv.Txn(context.TODO()).If(
clientv3.Compare(
clientv3.CreateRevision("foo/"), "=", fooResp.Header.Revision).
WithPrefix(),
).Commit()
if terr != nil {
t.Fatal(terr)
}
if tresp.Succeeded {
t.Fatal("expected prefix compare to false, got compares as true")
}
}

0 comments on commit 8f34d0c

Please sign in to comment.