store: replace testify asserts with testutil asserts
parent
6f06e1cb47
commit
978cf804ca
|
@ -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 {
|
||||
|
|
|
@ -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, "")
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue