|
|
@@ -58,34 +58,34 @@ func runTestsForClient(t *testing.T, client CacheStorage) {
|
|
|
func canPutGetAndDeleteCachedObjects(t *testing.T, client CacheStorage) {
|
|
|
cacheableStruct := CacheableStruct{String: "hej", Int64: 2000}
|
|
|
|
|
|
- err := client.Set("key", cacheableStruct, 0)
|
|
|
- assert.Equal(t, err, nil)
|
|
|
+ err := client.Set("key1", cacheableStruct, 0)
|
|
|
+ assert.Equal(t, err, nil, "expected nil. got: ", err)
|
|
|
|
|
|
- data, err := client.Get("key")
|
|
|
+ data, err := client.Get("key1")
|
|
|
s, ok := data.(CacheableStruct)
|
|
|
|
|
|
assert.Equal(t, ok, true)
|
|
|
assert.Equal(t, s.String, "hej")
|
|
|
assert.Equal(t, s.Int64, int64(2000))
|
|
|
|
|
|
- err = client.Delete("key")
|
|
|
+ err = client.Delete("key1")
|
|
|
assert.Equal(t, err, nil)
|
|
|
|
|
|
- _, err = client.Get("key")
|
|
|
+ _, err = client.Get("key1")
|
|
|
assert.Equal(t, err, ErrCacheItemNotFound)
|
|
|
}
|
|
|
|
|
|
func canNotFetchExpiredItems(t *testing.T, client CacheStorage) {
|
|
|
cacheableStruct := CacheableStruct{String: "hej", Int64: 2000}
|
|
|
|
|
|
- err := client.Set("key", cacheableStruct, time.Second)
|
|
|
+ err := client.Set("key1", cacheableStruct, time.Second)
|
|
|
assert.Equal(t, err, nil)
|
|
|
|
|
|
//not sure how this can be avoided when testing redis/memcached :/
|
|
|
<-time.After(time.Second + time.Millisecond)
|
|
|
|
|
|
// should not be able to read that value since its expired
|
|
|
- _, err = client.Get("key")
|
|
|
+ _, err = client.Get("key1")
|
|
|
assert.Equal(t, err, ErrCacheItemNotFound)
|
|
|
}
|
|
|
|
|
|
@@ -94,12 +94,12 @@ func canSetInfiniteCacheExpiration(t *testing.T, client CacheStorage) {
|
|
|
|
|
|
// insert cache item one day back
|
|
|
getTime = func() time.Time { return time.Now().AddDate(0, 0, -2) }
|
|
|
- err := client.Set("key", cacheableStruct, 0)
|
|
|
+ err := client.Set("key1", cacheableStruct, 0)
|
|
|
assert.Equal(t, err, nil)
|
|
|
|
|
|
// should not be able to read that value since its expired
|
|
|
getTime = time.Now
|
|
|
- data, err := client.Get("key")
|
|
|
+ data, err := client.Get("key1")
|
|
|
s, ok := data.(CacheableStruct)
|
|
|
|
|
|
assert.Equal(t, ok, true)
|