mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: clean up if, bool comparison
This commit is contained in:
parent
dc0061e4db
commit
b0cc0e443c
@ -124,7 +124,7 @@ func testWatchMultiWatcher(t *testing.T, wctx *watchctx) {
|
||||
got = append(got, string(ev.Kv.Value))
|
||||
}
|
||||
sort.Strings(got)
|
||||
if reflect.DeepEqual(expected, got) == false {
|
||||
if !reflect.DeepEqual(expected, got) {
|
||||
t.Errorf("got %v, expected %v", got, expected)
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ func OpDelete(key string, opts ...OpOption) Op {
|
||||
panic("unexpected revision in delete")
|
||||
case ret.sort != nil:
|
||||
panic("unexpected sort in delete")
|
||||
case ret.serializable != false:
|
||||
case ret.serializable:
|
||||
panic("unexpected serializable in delete")
|
||||
}
|
||||
return ret
|
||||
@ -113,7 +113,7 @@ func OpPut(key, val string, opts ...OpOption) Op {
|
||||
panic("unexpected revision in put")
|
||||
case ret.sort != nil:
|
||||
panic("unexpected sort in put")
|
||||
case ret.serializable != false:
|
||||
case ret.serializable:
|
||||
panic("unexpected serializable in delete")
|
||||
}
|
||||
return ret
|
||||
@ -129,7 +129,7 @@ func opWatch(key string, opts ...OpOption) Op {
|
||||
panic("unexpected limit in watch")
|
||||
case ret.sort != nil:
|
||||
panic("unexpected sort in watch")
|
||||
case ret.serializable != false:
|
||||
case ret.serializable:
|
||||
panic("unexpected serializable in watch")
|
||||
}
|
||||
return ret
|
||||
|
@ -521,7 +521,7 @@ func (w *watcher) resumeWatchers(wc pb.Watch_WatchClient) error {
|
||||
resp, err := wc.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
} else if len(resp.Events) != 0 || resp.Created != true {
|
||||
} else if len(resp.Events) != 0 || !resp.Created {
|
||||
return fmt.Errorf("watcher: unexpected response (%+v)", resp)
|
||||
}
|
||||
|
||||
|
@ -275,7 +275,7 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster,
|
||||
}
|
||||
|
||||
func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
|
||||
if fileutil.Exist("../bin/etcd") == false {
|
||||
if !fileutil.Exist("../bin/etcd") {
|
||||
return nil, fmt.Errorf("could not find etcd binary")
|
||||
}
|
||||
if err := os.RemoveAll(cfg.dataDirPath); err != nil {
|
||||
|
@ -563,7 +563,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
if shouldStop != false {
|
||||
if shouldStop {
|
||||
t.Errorf("shouldStop = %t, want %t", shouldStop, false)
|
||||
}
|
||||
|
||||
@ -573,7 +573,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error %v", err)
|
||||
}
|
||||
if shouldStop != true {
|
||||
if !shouldStop {
|
||||
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
||||
}
|
||||
}
|
||||
@ -610,7 +610,7 @@ func TestApplyMultiConfChangeShouldStop(t *testing.T) {
|
||||
}
|
||||
|
||||
_, shouldStop := srv.apply(ents, &raftpb.ConfState{})
|
||||
if shouldStop == false {
|
||||
if !shouldStop {
|
||||
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ func TestV3DeleteRange(t *testing.T) {
|
||||
for j := range rresp.Kvs {
|
||||
keys = append(keys, rresp.Kvs[j].Key)
|
||||
}
|
||||
if reflect.DeepEqual(tt.wantSet, keys) == false {
|
||||
if !reflect.DeepEqual(tt.wantSet, keys) {
|
||||
t.Errorf("expected %v on test %v, got %v", tt.wantSet, i, keys)
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ func TestV3WatchFromCurrentRevision(t *testing.T) {
|
||||
t.Errorf("#%d: wStream.Recv error: %v", i, err)
|
||||
continue
|
||||
}
|
||||
if cresp.Created != true {
|
||||
if !cresp.Created {
|
||||
t.Errorf("#%d: did not create watchid, got +%v", i, cresp)
|
||||
continue
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ func TestExist(t *testing.T) {
|
||||
}
|
||||
f.Close()
|
||||
|
||||
if g := Exist(f.Name()); g != true {
|
||||
if g := Exist(f.Name()); !g {
|
||||
t.Errorf("exist = %v, want true", g)
|
||||
}
|
||||
|
||||
os.Remove(f.Name())
|
||||
if g := Exist(f.Name()); g != false {
|
||||
if g := Exist(f.Name()); g {
|
||||
t.Errorf("exist = %v, want false", g)
|
||||
}
|
||||
}
|
||||
|
@ -131,14 +131,7 @@ func (ki *keyIndex) get(atRev int64) (modified, created revision, ver int64, err
|
||||
return revision{}, revision{}, 0, ErrRevisionNotFound
|
||||
}
|
||||
|
||||
f := func(rev revision) bool {
|
||||
if rev.main <= atRev {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
n := g.walk(f)
|
||||
n := g.walk(func(rev revision) bool { return rev.main > atRev })
|
||||
if n != -1 {
|
||||
return g.revs[n], g.created, g.ver - int64(len(g.revs)-n-1), nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user