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))
|
got = append(got, string(ev.Kv.Value))
|
||||||
}
|
}
|
||||||
sort.Strings(got)
|
sort.Strings(got)
|
||||||
if reflect.DeepEqual(expected, got) == false {
|
if !reflect.DeepEqual(expected, got) {
|
||||||
t.Errorf("got %v, expected %v", got, expected)
|
t.Errorf("got %v, expected %v", got, expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func OpDelete(key string, opts ...OpOption) Op {
|
|||||||
panic("unexpected revision in delete")
|
panic("unexpected revision in delete")
|
||||||
case ret.sort != nil:
|
case ret.sort != nil:
|
||||||
panic("unexpected sort in delete")
|
panic("unexpected sort in delete")
|
||||||
case ret.serializable != false:
|
case ret.serializable:
|
||||||
panic("unexpected serializable in delete")
|
panic("unexpected serializable in delete")
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
@ -113,7 +113,7 @@ func OpPut(key, val string, opts ...OpOption) Op {
|
|||||||
panic("unexpected revision in put")
|
panic("unexpected revision in put")
|
||||||
case ret.sort != nil:
|
case ret.sort != nil:
|
||||||
panic("unexpected sort in put")
|
panic("unexpected sort in put")
|
||||||
case ret.serializable != false:
|
case ret.serializable:
|
||||||
panic("unexpected serializable in delete")
|
panic("unexpected serializable in delete")
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
@ -129,7 +129,7 @@ func opWatch(key string, opts ...OpOption) Op {
|
|||||||
panic("unexpected limit in watch")
|
panic("unexpected limit in watch")
|
||||||
case ret.sort != nil:
|
case ret.sort != nil:
|
||||||
panic("unexpected sort in watch")
|
panic("unexpected sort in watch")
|
||||||
case ret.serializable != false:
|
case ret.serializable:
|
||||||
panic("unexpected serializable in watch")
|
panic("unexpected serializable in watch")
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
|
@ -521,7 +521,7 @@ func (w *watcher) resumeWatchers(wc pb.Watch_WatchClient) error {
|
|||||||
resp, err := wc.Recv()
|
resp, err := wc.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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)
|
return fmt.Errorf("watcher: unexpected response (%+v)", resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ func newEtcdProcessCluster(cfg *etcdProcessClusterConfig) (*etcdProcessCluster,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newEtcdProcess(cfg *etcdProcessConfig) (*etcdProcess, error) {
|
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")
|
return nil, fmt.Errorf("could not find etcd binary")
|
||||||
}
|
}
|
||||||
if err := os.RemoveAll(cfg.dataDirPath); err != nil {
|
if err := os.RemoveAll(cfg.dataDirPath); err != nil {
|
||||||
|
@ -563,7 +563,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error %v", err)
|
t.Fatalf("unexpected error %v", err)
|
||||||
}
|
}
|
||||||
if shouldStop != false {
|
if shouldStop {
|
||||||
t.Errorf("shouldStop = %t, want %t", shouldStop, false)
|
t.Errorf("shouldStop = %t, want %t", shouldStop, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ func TestApplyConfChangeShouldStop(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error %v", err)
|
t.Fatalf("unexpected error %v", err)
|
||||||
}
|
}
|
||||||
if shouldStop != true {
|
if !shouldStop {
|
||||||
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ func TestApplyMultiConfChangeShouldStop(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_, shouldStop := srv.apply(ents, &raftpb.ConfState{})
|
_, shouldStop := srv.apply(ents, &raftpb.ConfState{})
|
||||||
if shouldStop == false {
|
if !shouldStop {
|
||||||
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
t.Errorf("shouldStop = %t, want %t", shouldStop, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,7 +362,7 @@ func TestV3DeleteRange(t *testing.T) {
|
|||||||
for j := range rresp.Kvs {
|
for j := range rresp.Kvs {
|
||||||
keys = append(keys, rresp.Kvs[j].Key)
|
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)
|
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)
|
t.Errorf("#%d: wStream.Recv error: %v", i, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cresp.Created != true {
|
if !cresp.Created {
|
||||||
t.Errorf("#%d: did not create watchid, got +%v", i, cresp)
|
t.Errorf("#%d: did not create watchid, got +%v", i, cresp)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -87,12 +87,12 @@ func TestExist(t *testing.T) {
|
|||||||
}
|
}
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
if g := Exist(f.Name()); g != true {
|
if g := Exist(f.Name()); !g {
|
||||||
t.Errorf("exist = %v, want true", g)
|
t.Errorf("exist = %v, want true", g)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Remove(f.Name())
|
os.Remove(f.Name())
|
||||||
if g := Exist(f.Name()); g != false {
|
if g := Exist(f.Name()); g {
|
||||||
t.Errorf("exist = %v, want false", 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
|
return revision{}, revision{}, 0, ErrRevisionNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
f := func(rev revision) bool {
|
n := g.walk(func(rev revision) bool { return rev.main > atRev })
|
||||||
if rev.main <= atRev {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
n := g.walk(f)
|
|
||||||
if n != -1 {
|
if n != -1 {
|
||||||
return g.revs[n], g.created, g.ver - int64(len(g.revs)-n-1), nil
|
return g.revs[n], g.created, g.ver - int64(len(g.revs)-n-1), nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user