2016-05-13 06:50:58 +03:00
|
|
|
// Copyright 2016 The etcd Authors
|
2016-04-07 08:44:15 +03:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package clientv3
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-02-26 22:12:45 +03:00
|
|
|
"github.com/coreos/etcd/mvcc/mvccpb"
|
2016-04-07 08:44:15 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestEvent(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
ev *Event
|
|
|
|
isCreate bool
|
|
|
|
isModify bool
|
|
|
|
}{{
|
|
|
|
ev: &Event{
|
|
|
|
Type: EventTypePut,
|
2016-04-25 22:32:58 +03:00
|
|
|
Kv: &mvccpb.KeyValue{
|
2016-04-07 08:44:15 +03:00
|
|
|
CreateRevision: 3,
|
|
|
|
ModRevision: 3,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
isCreate: true,
|
|
|
|
}, {
|
|
|
|
ev: &Event{
|
|
|
|
Type: EventTypePut,
|
2016-04-25 22:32:58 +03:00
|
|
|
Kv: &mvccpb.KeyValue{
|
2016-04-07 08:44:15 +03:00
|
|
|
CreateRevision: 3,
|
|
|
|
ModRevision: 4,
|
|
|
|
},
|
|
|
|
},
|
2017-05-05 16:58:39 +03:00
|
|
|
isModify: true,
|
2016-04-07 08:44:15 +03:00
|
|
|
}}
|
|
|
|
for i, tt := range tests {
|
|
|
|
if tt.isCreate && !tt.ev.IsCreate() {
|
|
|
|
t.Errorf("#%d: event should be Create event", i)
|
|
|
|
}
|
|
|
|
if tt.isModify && !tt.ev.IsModify() {
|
|
|
|
t.Errorf("#%d: event should be Modify event", i)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|