mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3/integration: test compare on range
This commit is contained in:
parent
7ff6e62c56
commit
8f34d0c8b6
@ -152,3 +152,30 @@ func TestTxnSuccess(t *testing.T) {
|
|||||||
t.Fatalf("unexpected Get response %v", resp)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user