File tree 2 files changed +7
-1
lines changed
2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ func TestV3PutOverwrite(t *testing.T) {
44
44
45
45
kvc := toGRPC (clus .RandClient ()).KV
46
46
key := []byte ("foo" )
47
- reqput := & pb.PutRequest {Key : key , Value : []byte ("bar" )}
47
+ reqput := & pb.PutRequest {Key : key , Value : []byte ("bar" ), PrevKv : true }
48
48
49
49
respput , err := kvc .Put (context .TODO (), reqput )
50
50
if err != nil {
@@ -61,6 +61,9 @@ func TestV3PutOverwrite(t *testing.T) {
61
61
t .Fatalf ("expected newer revision on overwrite, got %v <= %v" ,
62
62
respput2 .Header .Revision , respput .Header .Revision )
63
63
}
64
+ if pkv := respput2 .PrevKv ; pkv == nil || string (pkv .Value ) != "bar" {
65
+ t .Fatalf ("expected PrevKv=bar, got response %+v" , respput2 )
66
+ }
64
67
65
68
reqrange := & pb.RangeRequest {Key : key }
66
69
resprange , err := kvc .Range (context .TODO (), reqrange )
Original file line number Diff line number Diff line change @@ -196,6 +196,9 @@ func PutRequestToOp(r *pb.PutRequest) clientv3.Op {
196
196
if r .IgnoreLease {
197
197
opts = append (opts , clientv3 .WithIgnoreLease ())
198
198
}
199
+ if r .PrevKv {
200
+ opts = append (opts , clientv3 .WithPrevKV ())
201
+ }
199
202
return clientv3 .OpPut (string (r .Key ), string (r .Value ), opts ... )
200
203
}
201
204
You can’t perform that action at this time.
0 commit comments