go.etcd.io/etcd@v3.3.27+incompatible/clientv3/watch_test.go (about) 1 // Copyright 2016 The etcd Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package clientv3 16 17 import ( 18 "testing" 19 20 "github.com/coreos/etcd/mvcc/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 }