...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package clientv3
16
17 import (
18 "testing"
19
20 "go.etcd.io/etcd/api/v3/mvccpb"
21 )
22
23 func TestEvent(t *testing.T) {
24 tests := []struct {
25 ev *Event
26 isCreate bool
27 isModify bool
28 }{{
29 ev: &Event{
30 Type: EventTypePut,
31 Kv: &mvccpb.KeyValue{
32 CreateRevision: 3,
33 ModRevision: 3,
34 },
35 },
36 isCreate: true,
37 }, {
38 ev: &Event{
39 Type: EventTypePut,
40 Kv: &mvccpb.KeyValue{
41 CreateRevision: 3,
42 ModRevision: 4,
43 },
44 },
45 isModify: true,
46 }}
47 for i, tt := range tests {
48 if tt.isCreate && !tt.ev.IsCreate() {
49 t.Errorf("#%d: event should be Create event", i)
50 }
51 if tt.isModify && !tt.ev.IsModify() {
52 t.Errorf("#%d: event should be Modify event", i)
53 }
54 }
55 }
56
View as plain text