Refactor util clock into it's own pkg

This commit is contained in:
Harry Zhang
2016-05-25 23:08:56 -04:00
committed by Harry Zhang
parent 1c72ba6810
commit cb14b35bde
38 changed files with 127 additions and 125 deletions

View File

@@ -22,7 +22,7 @@ import (
"time"
expirationCache "k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/clock"
)
type testObject struct {
@@ -31,7 +31,7 @@ type testObject struct {
}
// A fake objectCache for unit test.
func NewFakeObjectCache(f func() (interface{}, error), ttl time.Duration, clock util.Clock) *ObjectCache {
func NewFakeObjectCache(f func() (interface{}, error), ttl time.Duration, clock clock.Clock) *ObjectCache {
ttlPolicy := &expirationCache.TTLPolicy{Ttl: ttl, Clock: clock}
deleteChan := make(chan string, 1)
return &ObjectCache{
@@ -47,7 +47,7 @@ func TestAddAndGet(t *testing.T) {
}
objectCache := NewFakeObjectCache(func() (interface{}, error) {
return nil, fmt.Errorf("Unexpected Error: updater should never be called in this test!")
}, 1*time.Hour, util.NewFakeClock(time.Now()))
}, 1*time.Hour, clock.NewFakeClock(time.Now()))
err := objectCache.Add(testObj.key, testObj.val)
if err != nil {
@@ -72,7 +72,7 @@ func TestExpirationBasic(t *testing.T) {
val: unexpectedVal,
}
fakeClock := util.NewFakeClock(time.Now())
fakeClock := clock.NewFakeClock(time.Now())
objectCache := NewFakeObjectCache(func() (interface{}, error) {
return expectedVal, nil