From 978cf804cad5f72355cf2c68f1a8188d3f141121 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Sat, 22 Apr 2017 18:30:52 -0700 Subject: [PATCH] store: replace testify asserts with testutil asserts --- store/node_extern_test.go | 45 +-- store/stats_test.go | 26 +- store/store_test.go | 712 +++++++++++++++++++------------------- 3 files changed, 392 insertions(+), 391 deletions(-) diff --git a/store/node_extern_test.go b/store/node_extern_test.go index 8caf16173..7875e47f9 100644 --- a/store/node_extern_test.go +++ b/store/node_extern_test.go @@ -19,8 +19,9 @@ import ( "testing" "time" "unsafe" + + "github.com/coreos/etcd/pkg/testutil" ) -import "github.com/stretchr/testify/assert" func TestNodeExternClone(t *testing.T) { var eNode *NodeExtern @@ -56,15 +57,15 @@ func TestNodeExternClone(t *testing.T) { gNode := eNode.Clone() // Check the clone is as expected - assert.Equal(t, gNode.Key, key) - assert.Equal(t, gNode.TTL, ttl) - assert.Equal(t, gNode.CreatedIndex, ci) - assert.Equal(t, gNode.ModifiedIndex, mi) + testutil.AssertEqual(t, gNode.Key, key) + testutil.AssertEqual(t, gNode.TTL, ttl) + testutil.AssertEqual(t, gNode.CreatedIndex, ci) + testutil.AssertEqual(t, gNode.ModifiedIndex, mi) // values should be the same - assert.Equal(t, *gNode.Value, val) - assert.Equal(t, *gNode.Expiration, exp) - assert.Equal(t, len(gNode.Nodes), len(childs)) - assert.Equal(t, *gNode.Nodes[0], child) + testutil.AssertEqual(t, *gNode.Value, val) + testutil.AssertEqual(t, *gNode.Expiration, exp) + testutil.AssertEqual(t, len(gNode.Nodes), len(childs)) + testutil.AssertEqual(t, *gNode.Nodes[0], child) // but pointers should differ if gNode.Value == eNode.Value { t.Fatalf("expected value pointers to differ, but got same!") @@ -76,12 +77,12 @@ func TestNodeExternClone(t *testing.T) { t.Fatalf("expected nodes pointers to differ, but got same!") } // Original should be the same - assert.Equal(t, eNode.Key, key) - assert.Equal(t, eNode.TTL, ttl) - assert.Equal(t, eNode.CreatedIndex, ci) - assert.Equal(t, eNode.ModifiedIndex, mi) - assert.Equal(t, eNode.Value, valp) - assert.Equal(t, eNode.Expiration, expp) + testutil.AssertEqual(t, eNode.Key, key) + testutil.AssertEqual(t, eNode.TTL, ttl) + testutil.AssertEqual(t, eNode.CreatedIndex, ci) + testutil.AssertEqual(t, eNode.ModifiedIndex, mi) + testutil.AssertEqual(t, eNode.Value, valp) + testutil.AssertEqual(t, eNode.Expiration, expp) if !sameSlice(eNode.Nodes, childs) { t.Fatalf("expected nodes pointer to same, but got different!") } @@ -89,15 +90,15 @@ func TestNodeExternClone(t *testing.T) { gNode.Key = "/baz" gNode.TTL = 0 gNode.Nodes[0].Key = "uno" - assert.Equal(t, eNode.Key, key) - assert.Equal(t, eNode.TTL, ttl) - assert.Equal(t, eNode.CreatedIndex, ci) - assert.Equal(t, eNode.ModifiedIndex, mi) - assert.Equal(t, *eNode.Nodes[0], child) + testutil.AssertEqual(t, eNode.Key, key) + testutil.AssertEqual(t, eNode.TTL, ttl) + testutil.AssertEqual(t, eNode.CreatedIndex, ci) + testutil.AssertEqual(t, eNode.ModifiedIndex, mi) + testutil.AssertEqual(t, *eNode.Nodes[0], child) // Change the original and ensure the clone is not affected eNode.Key = "/wuf" - assert.Equal(t, eNode.Key, "/wuf") - assert.Equal(t, gNode.Key, "/baz") + testutil.AssertEqual(t, eNode.Key, "/wuf") + testutil.AssertEqual(t, gNode.Key, "/baz") } func sameSlice(a, b []*NodeExtern) bool { diff --git a/store/stats_test.go b/store/stats_test.go index 44efbf9f5..ec105a586 100644 --- a/store/stats_test.go +++ b/store/stats_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/stretchr/testify/assert" + "github.com/coreos/etcd/pkg/testutil" ) // Ensure that a successful Get is recorded in the stats. @@ -26,7 +26,7 @@ func TestStoreStatsGetSuccess(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Get("/foo", false, false) - assert.Equal(t, uint64(1), s.Stats.GetSuccess, "") + testutil.AssertEqual(t, uint64(1), s.Stats.GetSuccess, "") } // Ensure that a failed Get is recorded in the stats. @@ -34,14 +34,14 @@ func TestStoreStatsGetFail(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Get("/no_such_key", false, false) - assert.Equal(t, uint64(1), s.Stats.GetFail, "") + testutil.AssertEqual(t, uint64(1), s.Stats.GetFail, "") } // Ensure that a successful Create is recorded in the stats. func TestStoreStatsCreateSuccess(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.CreateSuccess, "") + testutil.AssertEqual(t, uint64(1), s.Stats.CreateSuccess, "") } // Ensure that a failed Create is recorded in the stats. @@ -49,7 +49,7 @@ func TestStoreStatsCreateFail(t *testing.T) { s := newStore() s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.CreateFail, "") + testutil.AssertEqual(t, uint64(1), s.Stats.CreateFail, "") } // Ensure that a successful Update is recorded in the stats. @@ -57,14 +57,14 @@ func TestStoreStatsUpdateSuccess(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.UpdateSuccess, "") + testutil.AssertEqual(t, uint64(1), s.Stats.UpdateSuccess, "") } // Ensure that a failed Update is recorded in the stats. func TestStoreStatsUpdateFail(t *testing.T) { s := newStore() s.Update("/foo", "bar", TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.UpdateFail, "") + testutil.AssertEqual(t, uint64(1), s.Stats.UpdateFail, "") } // Ensure that a successful CAS is recorded in the stats. @@ -72,7 +72,7 @@ func TestStoreStatsCompareAndSwapSuccess(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.CompareAndSwapSuccess, "") + testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapSuccess, "") } // Ensure that a failed CAS is recorded in the stats. @@ -80,7 +80,7 @@ func TestStoreStatsCompareAndSwapFail(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Equal(t, uint64(1), s.Stats.CompareAndSwapFail, "") + testutil.AssertEqual(t, uint64(1), s.Stats.CompareAndSwapFail, "") } // Ensure that a successful Delete is recorded in the stats. @@ -88,14 +88,14 @@ func TestStoreStatsDeleteSuccess(t *testing.T) { s := newStore() s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Delete("/foo", false, false) - assert.Equal(t, uint64(1), s.Stats.DeleteSuccess, "") + testutil.AssertEqual(t, uint64(1), s.Stats.DeleteSuccess, "") } // Ensure that a failed Delete is recorded in the stats. func TestStoreStatsDeleteFail(t *testing.T) { s := newStore() s.Delete("/foo", false, false) - assert.Equal(t, uint64(1), s.Stats.DeleteFail, "") + testutil.AssertEqual(t, uint64(1), s.Stats.DeleteFail, "") } //Ensure that the number of expirations is recorded in the stats. @@ -105,8 +105,8 @@ func TestStoreStatsExpireCount(t *testing.T) { s.clock = fc s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) - assert.Equal(t, uint64(0), s.Stats.ExpireCount, "") + testutil.AssertEqual(t, uint64(0), s.Stats.ExpireCount, "") fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) - assert.Equal(t, uint64(1), s.Stats.ExpireCount, "") + testutil.AssertEqual(t, uint64(1), s.Stats.ExpireCount, "") } diff --git a/store/store_test.go b/store/store_test.go index 1a4527352..49f6fc620 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -19,17 +19,17 @@ import ( "time" etcdErr "github.com/coreos/etcd/error" + "github.com/coreos/etcd/pkg/testutil" "github.com/jonboulle/clockwork" - "github.com/stretchr/testify/assert" ) func TestNewStoreWithNamespaces(t *testing.T) { s := newStore("/0", "/1") _, err := s.Get("/0", false, false) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) _, err = s.Get("/1", false, false) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) } // Ensure that the store can retrieve an existing value. @@ -38,11 +38,11 @@ func TestStoreGetValue(t *testing.T) { s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) var eidx uint64 = 1 e, err := s.Get("/foo", false, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "get", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "get") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, *e.Node.Value, "bar") } // Ensure that any TTL <= minExpireTime becomes Permanent @@ -51,18 +51,18 @@ func TestMinExpireTime(t *testing.T) { fc := clockwork.NewFakeClock() s.clock = fc // FakeClock starts at 0, so minExpireTime should be far in the future.. but just in case - assert.True(t, minExpireTime.After(fc.Now()), "minExpireTime should be ahead of FakeClock!") + testutil.AssertTrue(t, minExpireTime.After(fc.Now()), "minExpireTime should be ahead of FakeClock!") s.Create("/foo", false, "Y", false, TTLOptionSet{ExpireTime: fc.Now().Add(3 * time.Second)}) fc.Advance(5 * time.Second) // Ensure it hasn't expired s.DeleteExpiredKeys(fc.Now()) var eidx uint64 = 1 e, err := s.Get("/foo", true, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "get", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, e.Node.TTL, int64(0)) + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "get") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, e.Node.TTL, int64(0)) } // Ensure that the store can recursively retrieve a directory listing. @@ -80,20 +80,20 @@ func TestStoreGetDirectory(t *testing.T) { s.Create("/foo/baz/ttl", false, "Y", false, TTLOptionSet{ExpireTime: fc.Now().Add(time.Second * 3)}) var eidx uint64 = 7 e, err := s.Get("/foo", true, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "get", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, len(e.Node.Nodes), 2, "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "get") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, len(e.Node.Nodes), 2) var bazNodes NodeExterns for _, node := range e.Node.Nodes { switch node.Key { case "/foo/bar": - assert.Equal(t, *node.Value, "X", "") - assert.Equal(t, node.Dir, false, "") + testutil.AssertEqual(t, *node.Value, "X") + testutil.AssertEqual(t, node.Dir, false) case "/foo/baz": - assert.Equal(t, node.Dir, true, "") - assert.Equal(t, len(node.Nodes), 2, "") + testutil.AssertEqual(t, node.Dir, true) + testutil.AssertEqual(t, len(node.Nodes), 2) bazNodes = node.Nodes default: t.Errorf("key = %s, not matched", node.Key) @@ -102,12 +102,12 @@ func TestStoreGetDirectory(t *testing.T) { for _, node := range bazNodes { switch node.Key { case "/foo/baz/bat": - assert.Equal(t, *node.Value, "Y", "") - assert.Equal(t, node.Dir, false, "") + testutil.AssertEqual(t, *node.Value, "Y") + testutil.AssertEqual(t, node.Dir, false) case "/foo/baz/ttl": - assert.Equal(t, *node.Value, "Y", "") - assert.Equal(t, node.Dir, false, "") - assert.Equal(t, node.TTL, int64(3), "") + testutil.AssertEqual(t, *node.Value, "Y") + testutil.AssertEqual(t, node.Dir, false) + testutil.AssertEqual(t, node.TTL, int64(3)) default: t.Errorf("key = %s, not matched", node.Key) } @@ -125,8 +125,8 @@ func TestStoreGetSorted(t *testing.T) { s.Create("/foo/y/b", false, "0", false, TTLOptionSet{ExpireTime: Permanent}) var eidx uint64 = 6 e, err := s.Get("/foo", true, true) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) var yNodes NodeExterns sortedStrings := []string{"/foo/x", "/foo/y", "/foo/z"} @@ -155,67 +155,67 @@ func TestSet(t *testing.T) { // Set /foo="" var eidx uint64 = 1 e, err := s.Set("/foo", false, "", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "set", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "", "") - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(1), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "set") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "") + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1)) // Set /foo="bar" eidx = 2 e, err = s.Set("/foo", false, "bar", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "set", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "bar", "") - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(2), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "set") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "bar") + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) // Set /foo="baz" (for testing prevNode) eidx = 3 e, err = s.Set("/foo", false, "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "set", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(3), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "set") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(2), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2)) // Set /dir as a directory eidx = 4 e, err = s.Set("/dir", true, "", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "set", "") - assert.Equal(t, e.Node.Key, "/dir", "") - assert.True(t, e.Node.Dir, "") - assert.Nil(t, e.Node.Value) - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(4), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "set") + testutil.AssertEqual(t, e.Node.Key, "/dir") + testutil.AssertTrue(t, e.Node.Dir) + testutil.AssertNil(t, e.Node.Value) + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(4)) } // Ensure that the store can create a new key if it doesn't already exist. @@ -224,30 +224,30 @@ func TestStoreCreateValue(t *testing.T) { // Create /foo=bar var eidx uint64 = 1 e, err := s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "bar", "") - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(1), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "bar") + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(1)) // Create /empty="" eidx = 2 e, err = s.Create("/empty", false, "", false, TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/empty", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "", "") - assert.Nil(t, e.Node.Nodes, "") - assert.Nil(t, e.Node.Expiration, "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(2), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/empty") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "") + testutil.AssertNil(t, e.Node.Nodes) + testutil.AssertNil(t, e.Node.Expiration) + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) } @@ -256,11 +256,11 @@ func TestStoreCreateDirectory(t *testing.T) { s := newStore() var eidx uint64 = 1 e, err := s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.True(t, e.Node.Dir, "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertTrue(t, e.Node.Dir) } // Ensure that the store fails to create a key if it already exists. @@ -272,11 +272,11 @@ func TestStoreCreateFailsIfExists(t *testing.T) { // create /foo as dir again e, _err := s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeNodeExist, "") - assert.Equal(t, err.Message, "Key already exists", "") - assert.Equal(t, err.Cause, "/foo", "") - assert.Equal(t, err.Index, uint64(1), "") - assert.Nil(t, e, 0, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNodeExist) + testutil.AssertEqual(t, err.Message, "Key already exists") + testutil.AssertEqual(t, err.Cause, "/foo") + testutil.AssertEqual(t, err.Index, uint64(1)) + testutil.AssertNil(t, e) } // Ensure that the store can update a key if it already exists. @@ -287,44 +287,44 @@ func TestStoreUpdateValue(t *testing.T) { // update /foo="bzr" var eidx uint64 = 2 e, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(2), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(2)) // check prevNode - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.TTL, int64(0), "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.TTL, int64(0)) + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) e, _ = s.Get("/foo", false, false) - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertEqual(t, e.EtcdIndex, eidx) // update /foo="" eidx = 3 e, err = s.Update("/foo", "", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.False(t, e.Node.Dir, "") - assert.Equal(t, *e.Node.Value, "", "") - assert.Equal(t, e.Node.TTL, int64(0), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(3), "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertFalse(t, e.Node.Dir) + testutil.AssertEqual(t, *e.Node.Value, "") + testutil.AssertEqual(t, e.Node.TTL, int64(0)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) // check prevNode - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "baz", "") - assert.Equal(t, e.PrevNode.TTL, int64(0), "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(2), "") + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "baz") + testutil.AssertEqual(t, e.PrevNode.TTL, int64(0)) + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(2)) e, _ = s.Get("/foo", false, false) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, *e.Node.Value, "", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, *e.Node.Value, "") } // Ensure that the store cannot update a directory. @@ -333,10 +333,10 @@ func TestStoreUpdateFailsIfDirectory(t *testing.T) { s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeNotFile, "") - assert.Equal(t, err.Message, "Not a file", "") - assert.Equal(t, err.Cause, "/foo", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile) + testutil.AssertEqual(t, err.Message, "Not a file") + testutil.AssertEqual(t, err.Cause, "/foo") + testutil.AssertNil(t, e) } // Ensure that the store can update the TTL on a value. @@ -348,15 +348,15 @@ func TestStoreUpdateValueTTL(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) _, err := s.Update("/foo", "baz", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) e, _ := s.Get("/foo", false, false) - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertEqual(t, e.EtcdIndex, eidx) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) e, err = s.Get("/foo", false, false) - assert.Nil(t, e, "") - assert.Equal(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound, "") + testutil.AssertNil(t, e) + testutil.AssertEqual(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound) } // Ensure that the store can update the TTL on a directory. @@ -369,18 +369,18 @@ func TestStoreUpdateDirTTL(t *testing.T) { s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) - assert.Nil(t, err, "") - assert.Equal(t, e.Node.Dir, true, "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.Node.Dir, true) + testutil.AssertEqual(t, e.EtcdIndex, eidx) e, _ = s.Get("/foo/bar", false, false) - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertEqual(t, e.EtcdIndex, eidx) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) e, err = s.Get("/foo/bar", false, false) - assert.Nil(t, e, "") - assert.Equal(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound, "") + testutil.AssertNil(t, e) + testutil.AssertEqual(t, err.(*etcdErr.Error).ErrorCode, etcdErr.EcodeKeyNotFound) } // Ensure that the store can delete a value. @@ -389,13 +389,13 @@ func TestStoreDeleteValue(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.Delete("/foo", false, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "delete", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "delete") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") } // Ensure that the store can delete a directory if recursive is specified. @@ -407,28 +407,28 @@ func TestStoreDeleteDiretory(t *testing.T) { // delete /foo with dir = true and recursive = false // this should succeed, since the directory is empty e, err := s.Delete("/foo", true, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "delete", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "delete") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, e.PrevNode.Dir, true, "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, e.PrevNode.Dir, true) // create directory /foo and directory /foo/bar s.Create("/foo/bar", true, "", false, TTLOptionSet{ExpireTime: Permanent}) // delete /foo with dir = true and recursive = false // this should fail, since the directory is not empty _, err = s.Delete("/foo", true, false) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) // delete /foo with dir=false and recursive = true // this should succeed, since recursive implies dir=true // and recursively delete should be able to delete all // items under the given directory e, err = s.Delete("/foo", false, true) - assert.Nil(t, err, "") - assert.Equal(t, e.Action, "delete", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.Action, "delete") } @@ -439,9 +439,9 @@ func TestStoreDeleteDiretoryFailsIfNonRecursiveAndDir(t *testing.T) { s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.Delete("/foo", false, false) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeNotFile, "") - assert.Equal(t, err.Message, "Not a file", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile) + testutil.AssertEqual(t, err.Message, "Not a file") + testutil.AssertNil(t, e) } func TestRootRdOnly(t *testing.T) { @@ -449,19 +449,19 @@ func TestRootRdOnly(t *testing.T) { for _, tt := range []string{"/", "/0"} { _, err := s.Set(tt, true, "", TTLOptionSet{ExpireTime: Permanent}) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) _, err = s.Delete(tt, true, true) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) _, err = s.Create(tt, true, "", false, TTLOptionSet{ExpireTime: Permanent}) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) _, err = s.Update(tt, "", TTLOptionSet{ExpireTime: Permanent}) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) _, err = s.CompareAndSwap(tt, "", 0, "", TTLOptionSet{ExpireTime: Permanent}) - assert.NotNil(t, err, "") + testutil.AssertNotNil(t, err) } } @@ -470,17 +470,17 @@ func TestStoreCompareAndDeletePrevValue(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.CompareAndDelete("/foo", "bar", 0) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndDelete", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndDelete") + testutil.AssertEqual(t, e.Node.Key, "/foo") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") - assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) + testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) } func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) { @@ -489,12 +489,12 @@ func TestStoreCompareAndDeletePrevValueFailsIfNotMatch(t *testing.T) { s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.CompareAndDelete("/foo", "baz", 0) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeTestFailed, "") - assert.Equal(t, err.Message, "Compare failed", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed) + testutil.AssertEqual(t, err.Message, "Compare failed") + testutil.AssertNil(t, e) e, _ = s.Get("/foo", false, false) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, *e.Node.Value, "bar") } func TestStoreCompareAndDeletePrevIndex(t *testing.T) { @@ -502,15 +502,15 @@ func TestStoreCompareAndDeletePrevIndex(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.CompareAndDelete("/foo", "", 1) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndDelete", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndDelete") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") - assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) + testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) } func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) { @@ -518,14 +518,14 @@ func TestStoreCompareAndDeletePrevIndexFailsIfNotMatch(t *testing.T) { var eidx uint64 = 1 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.CompareAndDelete("/foo", "", 100) - assert.NotNil(t, _err, "") + testutil.AssertNotNil(t, _err) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeTestFailed, "") - assert.Equal(t, err.Message, "Compare failed", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed) + testutil.AssertEqual(t, err.Message, "Compare failed") + testutil.AssertNil(t, e) e, _ = s.Get("/foo", false, false) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, *e.Node.Value, "bar") } // Ensure that the store cannot delete a directory. @@ -533,9 +533,9 @@ func TestStoreCompareAndDeleteDiretoryFail(t *testing.T) { s := newStore() s.Create("/foo", true, "", false, TTLOptionSet{ExpireTime: Permanent}) _, _err := s.CompareAndDelete("/foo", "", 0) - assert.NotNil(t, _err, "") + testutil.AssertNotNil(t, _err) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeNotFile, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeNotFile) } // Ensure that the store can conditionally update a key if it has a previous value. @@ -544,19 +544,19 @@ func TestStoreCompareAndSwapPrevValue(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, *e.Node.Value, "baz", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndSwap") + testutil.AssertEqual(t, *e.Node.Value, "baz") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") - assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) + testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) e, _ = s.Get("/foo", false, false) - assert.Equal(t, *e.Node.Value, "baz", "") + testutil.AssertEqual(t, *e.Node.Value, "baz") } // Ensure that the store cannot conditionally update a key if it has the wrong previous value. @@ -566,12 +566,12 @@ func TestStoreCompareAndSwapPrevValueFailsIfNotMatch(t *testing.T) { s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.CompareAndSwap("/foo", "wrong_value", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeTestFailed, "") - assert.Equal(t, err.Message, "Compare failed", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed) + testutil.AssertEqual(t, err.Message, "Compare failed") + testutil.AssertNil(t, e) e, _ = s.Get("/foo", false, false) - assert.Equal(t, *e.Node.Value, "bar", "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertEqual(t, *e.Node.Value, "bar") + testutil.AssertEqual(t, e.EtcdIndex, eidx) } // Ensure that the store can conditionally update a key if it has a previous index. @@ -580,20 +580,20 @@ func TestStoreCompareAndSwapPrevIndex(t *testing.T) { var eidx uint64 = 2 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, err := s.CompareAndSwap("/foo", "", 1, "baz", TTLOptionSet{ExpireTime: Permanent}) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, *e.Node.Value, "baz", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndSwap") + testutil.AssertEqual(t, *e.Node.Value, "baz") // check prevNode - assert.NotNil(t, e.PrevNode, "") - assert.Equal(t, e.PrevNode.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") - assert.Equal(t, e.PrevNode.ModifiedIndex, uint64(1), "") - assert.Equal(t, e.PrevNode.CreatedIndex, uint64(1), "") + testutil.AssertNotNil(t, e.PrevNode) + testutil.AssertEqual(t, e.PrevNode.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") + testutil.AssertEqual(t, e.PrevNode.ModifiedIndex, uint64(1)) + testutil.AssertEqual(t, e.PrevNode.CreatedIndex, uint64(1)) e, _ = s.Get("/foo", false, false) - assert.Equal(t, *e.Node.Value, "baz", "") - assert.Equal(t, e.EtcdIndex, eidx, "") + testutil.AssertEqual(t, *e.Node.Value, "baz") + testutil.AssertEqual(t, e.EtcdIndex, eidx) } // Ensure that the store cannot conditionally update a key if it has the wrong previous index. @@ -603,12 +603,12 @@ func TestStoreCompareAndSwapPrevIndexFailsIfNotMatch(t *testing.T) { s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e, _err := s.CompareAndSwap("/foo", "", 100, "baz", TTLOptionSet{ExpireTime: Permanent}) err := _err.(*etcdErr.Error) - assert.Equal(t, err.ErrorCode, etcdErr.EcodeTestFailed, "") - assert.Equal(t, err.Message, "Compare failed", "") - assert.Nil(t, e, "") + testutil.AssertEqual(t, err.ErrorCode, etcdErr.EcodeTestFailed) + testutil.AssertEqual(t, err.Message, "Compare failed") + testutil.AssertNil(t, e) e, _ = s.Get("/foo", false, false) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, *e.Node.Value, "bar") } // Ensure that the store can watch for key creation. @@ -617,15 +617,15 @@ func TestStoreWatchCreate(t *testing.T) { var eidx uint64 = 0 w, _ := s.Watch("/foo", false, false, 0) c := w.EventChan() - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) eidx = 1 e := nbselect(c) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/foo") e = nbselect(c) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store can watch for recursive key creation. @@ -633,13 +633,13 @@ func TestStoreWatchRecursiveCreate(t *testing.T) { s := newStore() var eidx uint64 = 0 w, _ := s.Watch("/foo", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 1 s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/foo/bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/foo/bar") } // Ensure that the store can watch for key updates. @@ -648,13 +648,13 @@ func TestStoreWatchUpdate(t *testing.T) { var eidx uint64 = 1 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", false, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo") } // Ensure that the store can watch for recursive key updates. @@ -663,13 +663,13 @@ func TestStoreWatchRecursiveUpdate(t *testing.T) { var eidx uint64 = 1 s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.Update("/foo/bar", "baz", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo/bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo/bar") } // Ensure that the store can watch for key deletions. @@ -678,13 +678,13 @@ func TestStoreWatchDelete(t *testing.T) { var eidx uint64 = 1 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", false, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.Delete("/foo", false, false) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "delete", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "delete") + testutil.AssertEqual(t, e.Node.Key, "/foo") } // Ensure that the store can watch for recursive key deletions. @@ -693,13 +693,13 @@ func TestStoreWatchRecursiveDelete(t *testing.T) { var eidx uint64 = 1 s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.Delete("/foo/bar", false, false) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "delete", "") - assert.Equal(t, e.Node.Key, "/foo/bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "delete") + testutil.AssertEqual(t, e.Node.Key, "/foo/bar") } // Ensure that the store can watch for CAS updates. @@ -708,13 +708,13 @@ func TestStoreWatchCompareAndSwap(t *testing.T) { var eidx uint64 = 1 s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", false, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.CompareAndSwap("/foo", "bar", 0, "baz", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndSwap") + testutil.AssertEqual(t, e.Node.Key, "/foo") } // Ensure that the store can watch for recursive CAS updates. @@ -723,13 +723,13 @@ func TestStoreWatchRecursiveCompareAndSwap(t *testing.T) { var eidx uint64 = 1 s.Create("/foo/bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) w, _ := s.Watch("/foo", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) eidx = 2 s.CompareAndSwap("/foo/bar", "baz", 0, "bat", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "compareAndSwap", "") - assert.Equal(t, e.Node.Key, "/foo/bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "compareAndSwap") + testutil.AssertEqual(t, e.Node.Key, "/foo/bar") } // Ensure that the store can watch for key expiration. @@ -744,30 +744,30 @@ func TestStoreWatchExpire(t *testing.T) { s.Create("/foodir", true, "", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) w, _ := s.Watch("/", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) c := w.EventChan() e := nbselect(c) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) eidx = 4 e = nbselect(c) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foo") w, _ = s.Watch("/", true, false, 5) eidx = 6 - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) e = nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foofoo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foofoo") w, _ = s.Watch("/", true, false, 6) e = nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foodir", "") - assert.Equal(t, e.Node.Dir, true, "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foodir") + testutil.AssertEqual(t, e.Node.Dir, true) } // Ensure that the store can watch for key expiration when refreshing. @@ -782,28 +782,28 @@ func TestStoreWatchExpireRefresh(t *testing.T) { // Make sure we set watch updates when Refresh is true for newly created keys w, _ := s.Watch("/", true, false, 0) - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) c := w.EventChan() e := nbselect(c) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) eidx = 3 e = nbselect(c) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foo") s.Update("/foofoo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) w, _ = s.Watch("/", true, false, 4) fc.Advance(700 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) eidx = 5 // We should skip 4 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true - assert.Equal(t, w.StartIndex(), eidx-1, "") + testutil.AssertEqual(t, w.StartIndex(), eidx-1) e = nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foofoo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foofoo") } // Ensure that the store can watch for key expiration when refreshing with an empty value. @@ -823,12 +823,12 @@ func TestStoreWatchExpireEmptyRefresh(t *testing.T) { fc.Advance(700 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) eidx = 3 // We should skip 2 because a TTL update should occur with no watch notification if set `TTLOptionSet.Refresh` to true - assert.Equal(t, w.StartIndex(), eidx-1, "") + testutil.AssertEqual(t, w.StartIndex(), eidx-1) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") } // Update TTL of a key (set TTLOptionSet.Refresh to false) and send notification @@ -849,12 +849,12 @@ func TestStoreWatchNoRefresh(t *testing.T) { fc.Advance(700 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) eidx = 2 - assert.Equal(t, w.StartIndex(), eidx, "") + testutil.AssertEqual(t, w.StartIndex(), eidx) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, *e.PrevNode.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, *e.PrevNode.Value, "bar") } // Ensure that the store can update the TTL on a value with refresh. @@ -866,16 +866,16 @@ func TestStoreRefresh(t *testing.T) { s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) s.Create("/bar", true, "bar", false, TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond)}) _, err := s.Update("/foo", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) _, err = s.Set("/foo", false, "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) _, err = s.Update("/bar", "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) _, err = s.CompareAndSwap("/foo", "bar", 0, "", TTLOptionSet{ExpireTime: fc.Now().Add(500 * time.Millisecond), Refresh: true}) - assert.Nil(t, err, "") + testutil.AssertNil(t, err) } // Ensure that the store can watch in streaming mode. @@ -886,22 +886,22 @@ func TestStoreWatchStream(t *testing.T) { // first modification s.Create("/foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, *e.Node.Value, "bar") e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) // second modification eidx = 2 s.Update("/foo", "baz", TTLOptionSet{ExpireTime: Permanent}) e = nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/foo", "") - assert.Equal(t, *e.Node.Value, "baz", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/foo") + testutil.AssertEqual(t, *e.Node.Value, "baz") e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store can recover from a previously saved state. @@ -913,22 +913,22 @@ func TestStoreRecover(t *testing.T) { s.Update("/foo/x", "barbar", TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo/y", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) b, err := s.Save() - assert.Nil(t, err, "") + testutil.AssertNil(t, err) s2 := newStore() s2.Recovery(b) e, err := s.Get("/foo/x", false, false) - assert.Equal(t, e.Node.CreatedIndex, uint64(2), "") - assert.Equal(t, e.Node.ModifiedIndex, uint64(3), "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Nil(t, err, "") - assert.Equal(t, *e.Node.Value, "barbar", "") + testutil.AssertEqual(t, e.Node.CreatedIndex, uint64(2)) + testutil.AssertEqual(t, e.Node.ModifiedIndex, uint64(3)) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertNil(t, err) + testutil.AssertEqual(t, *e.Node.Value, "barbar") e, err = s.Get("/foo/y", false, false) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Nil(t, err, "") - assert.Equal(t, *e.Node.Value, "baz", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertNil(t, err) + testutil.AssertEqual(t, *e.Node.Value, "baz") } // Ensure that the store can recover from a previously saved state that includes an expiring key. @@ -943,7 +943,7 @@ func TestStoreRecoverWithExpiration(t *testing.T) { s.Create("/foo/x", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) s.Create("/foo/y", false, "baz", false, TTLOptionSet{ExpireTime: fc.Now().Add(5 * time.Millisecond)}) b, err := s.Save() - assert.Nil(t, err, "") + testutil.AssertNil(t, err) time.Sleep(10 * time.Millisecond) @@ -956,13 +956,13 @@ func TestStoreRecoverWithExpiration(t *testing.T) { s.DeleteExpiredKeys(fc.Now()) e, err := s.Get("/foo/x", false, false) - assert.Nil(t, err, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, *e.Node.Value, "bar", "") + testutil.AssertNil(t, err) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, *e.Node.Value, "bar") e, err = s.Get("/foo/y", false, false) - assert.NotNil(t, err, "") - assert.Nil(t, e, "") + testutil.AssertNotNil(t, err) + testutil.AssertNil(t, e) } // Ensure that the store can watch for hidden keys as long as it's an exact path match. @@ -972,11 +972,11 @@ func TestStoreWatchCreateWithHiddenKey(t *testing.T) { w, _ := s.Watch("/_foo", false, false, 0) s.Create("/_foo", false, "bar", false, TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/_foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/_foo") e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store doesn't see hidden key creates without an exact path match in recursive mode. @@ -985,14 +985,14 @@ func TestStoreWatchRecursiveCreateWithHiddenKey(t *testing.T) { w, _ := s.Watch("/foo", true, false, 0) s.Create("/foo/_bar", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) w, _ = s.Watch("/foo", true, false, 0) s.Create("/foo/_baz", true, "", false, TTLOptionSet{ExpireTime: Permanent}) e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) s.Create("/foo/_baz/quux", false, "quux", false, TTLOptionSet{ExpireTime: Permanent}) e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store doesn't see hidden key updates. @@ -1002,10 +1002,10 @@ func TestStoreWatchUpdateWithHiddenKey(t *testing.T) { w, _ := s.Watch("/_foo", false, false, 0) s.Update("/_foo", "baz", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Equal(t, e.Action, "update", "") - assert.Equal(t, e.Node.Key, "/_foo", "") + testutil.AssertEqual(t, e.Action, "update") + testutil.AssertEqual(t, e.Node.Key, "/_foo") e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store doesn't see hidden key updates without an exact path match in recursive mode. @@ -1015,7 +1015,7 @@ func TestStoreWatchRecursiveUpdateWithHiddenKey(t *testing.T) { w, _ := s.Watch("/foo", true, false, 0) s.Update("/foo/_bar", "baz", TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store can watch for key deletions. @@ -1026,11 +1026,11 @@ func TestStoreWatchDeleteWithHiddenKey(t *testing.T) { w, _ := s.Watch("/_foo", false, false, 0) s.Delete("/_foo", false, false) e := nbselect(w.EventChan()) - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "delete", "") - assert.Equal(t, e.Node.Key, "/_foo", "") + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "delete") + testutil.AssertEqual(t, e.Node.Key, "/_foo") e = nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store doesn't see hidden key deletes without an exact path match in recursive mode. @@ -1040,7 +1040,7 @@ func TestStoreWatchRecursiveDeleteWithHiddenKey(t *testing.T) { w, _ := s.Watch("/foo", true, false, 0) s.Delete("/foo/_bar", false, false) e := nbselect(w.EventChan()) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) } // Ensure that the store doesn't see expirations of hidden keys. @@ -1055,16 +1055,16 @@ func TestStoreWatchExpireWithHiddenKey(t *testing.T) { w, _ := s.Watch("/", true, false, 0) c := w.EventChan() e := nbselect(c) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) e = nbselect(c) - assert.Nil(t, e, "") + testutil.AssertNil(t, e) fc.Advance(600 * time.Millisecond) s.DeleteExpiredKeys(fc.Now()) e = nbselect(c) - assert.Equal(t, e.Action, "expire", "") - assert.Equal(t, e.Node.Key, "/foofoo", "") + testutil.AssertEqual(t, e.Action, "expire") + testutil.AssertEqual(t, e.Node.Key, "/foofoo") } // Ensure that the store does see hidden key creates if watching deeper than a hidden key in recursive mode. @@ -1075,10 +1075,10 @@ func TestStoreWatchRecursiveCreateDeeperThanHiddenKey(t *testing.T) { s.Create("/_foo/bar/baz", false, "baz", false, TTLOptionSet{ExpireTime: Permanent}) e := nbselect(w.EventChan()) - assert.NotNil(t, e, "") - assert.Equal(t, e.EtcdIndex, eidx, "") - assert.Equal(t, e.Action, "create", "") - assert.Equal(t, e.Node.Key, "/_foo/bar/baz", "") + testutil.AssertNotNil(t, e) + testutil.AssertEqual(t, e.EtcdIndex, eidx) + testutil.AssertEqual(t, e.Action, "create") + testutil.AssertEqual(t, e.Node.Key, "/_foo/bar/baz") } // Ensure that slow consumers are handled properly. @@ -1095,10 +1095,10 @@ func TestStoreWatchSlowConsumer(t *testing.T) { for i := 1; i <= 100; i++ { s.Set("/foo", false, string(i), TTLOptionSet{ExpireTime: Permanent}) // ok } - assert.Equal(t, s.WatcherHub.count, int64(1), "") + testutil.AssertEqual(t, s.WatcherHub.count, int64(1)) s.Set("/foo", false, "101", TTLOptionSet{ExpireTime: Permanent}) // ok // remove watcher - assert.Equal(t, s.WatcherHub.count, int64(0), "") + testutil.AssertEqual(t, s.WatcherHub.count, int64(0)) s.Set("/foo", false, "102", TTLOptionSet{ExpireTime: Permanent}) // must not panic }