Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: go/redisutil/redisutil_test.go

Issue 1401563003: Enable clear/purge for failed digests (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Added unit test to FileDiffStore Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | go/util/caching.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/redisutil/redisutil_test.go
diff --git a/go/redisutil/redisutil_test.go b/go/redisutil/redisutil_test.go
index a7bc84f15222ab56935e2abd568f21d739270dcf..57c3d70bc8a551834d047b154e49e138f88394d0 100644
--- a/go/redisutil/redisutil_test.go
+++ b/go/redisutil/redisutil_test.go
@@ -50,8 +50,8 @@ type TestStruct struct {
func TestRedisLRUCache(t *testing.T) {
testutils.SkipIfShort(t)
- cache := NewRedisLRUCache("localhost:6379", 1, "test-di", TestStructCodec(0))
- testLRUCache(t, cache)
+ cache := NewRedisLRUCache("localhost:6379", 1, "test-di", util.UnitTestCodec())
+ util.UnitTestLRUCache(t, cache)
}
func BenchmarkBigDataset(b *testing.B) {
@@ -147,57 +147,6 @@ func (t TestStructCodec) Decode(data []byte) (interface{}, error) {
return &v, err
}
-func testLRUCache(t *testing.T, cache util.LRUCache) {
- rlruCache := cache.(*RedisLRUCache)
- rlruCache.Purge()
- N := 256
- for i := 0; i < N; i++ {
- cache.Add(strconv.Itoa(i), i)
- }
-
- // Make sure out keys are correct
- assert.Equal(t, N, cache.Len())
- assert.Equal(t, N, len(rlruCache.Keys()))
- for _, k := range rlruCache.Keys() {
- assert.IsType(t, "", k)
- v, ok := cache.Get(k)
- assert.True(t, ok)
- assert.IsType(t, 0, v)
- assert.Equal(t, k, strconv.Itoa(v.(int)))
- }
-
- for i := 0; i < N; i++ {
- found, ok := cache.Get(strconv.Itoa(i))
- assert.True(t, ok)
- assert.IsType(t, 0, found)
- assert.Equal(t, found.(int), i)
- }
-
- for i := 0; i < N; i++ {
- _, ok := cache.Get(strconv.Itoa(i))
- assert.True(t, ok)
- oldLen := cache.Len()
- cache.Remove(strconv.Itoa(i))
- assert.Equal(t, oldLen-1, cache.Len())
- }
- assert.Equal(t, 0, cache.Len())
-
- // Add some TestStructs to make sure the codec works.
- for i := 0; i < N; i++ {
- strKey := "structkey-" + strconv.Itoa(i)
- ts := &TestStruct{
- PixelDiffFilePath: "somesting-" + strconv.Itoa(i),
- MaxRGBADiffs: []int{i * 4, i*4 + 1, i*4 + 2, i*4 + 3},
- }
- cache.Add(strKey, ts)
- assert.Equal(t, i+1, cache.Len())
- foundTS, ok := cache.Get(strKey)
- assert.True(t, ok)
- assert.IsType(t, &TestStruct{}, foundTS)
- assert.Equal(t, ts, foundTS)
- }
-}
-
type StringCodec struct{}
func (s StringCodec) Encode(data interface{}) ([]byte, error) {
« no previous file with comments | « no previous file | go/util/caching.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698