MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / TestRedisCacheError

Function TestRedisCacheError

pkg/cache/redis_test.go:95–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

93}
94
95func TestRedisCacheError(t *testing.T) {
96 c := newRedisCache()
97 defer c.Close()
98 testData := c.TestDataSlice[0].(*redisUser)
99 iCache := c.ICache.(Cache)
100
101 // Set empty key error test
102 key := utils.Uint64ToStr(testData.ID)
103 err := iCache.Set(c.Ctx, "", c.TestDataMap[key], time.Minute)
104 assert.Error(t, err)
105
106 // Set empty value error test
107 key = utils.Uint64ToStr(testData.ID)
108 err = iCache.Set(c.Ctx, key, nil, time.Minute)
109 assert.Error(t, err)
110
111 // Get empty key error test
112 val := &redisUser{}
113 err = iCache.Get(c.Ctx, "", val)
114 assert.Error(t, err)
115
116 // Get empty result test
117 key = utils.Uint64ToStr(testData.ID)
118 err = iCache.Get(c.Ctx, key, val)
119 assert.Error(t, err)
120
121 // Get result error test
122 key = utils.Uint64ToStr(testData.ID)
123 _ = iCache.Set(c.Ctx, key, c.TestDataMap[key], time.Minute)
124 time.Sleep(time.Millisecond)
125 err = iCache.Get(c.Ctx, key, nil)
126 assert.Error(t, err)
127
128 _ = iCache.MultiSet(c.Ctx, nil, time.Minute)
129 _ = iCache.MultiGet(c.Ctx, nil, time.Minute)
130
131 // Del empty key error test
132 err = iCache.Del(c.Ctx)
133 assert.NoError(t, err)
134 err = iCache.Del(c.Ctx, "")
135 assert.NoError(t, err)
136}
137
138func TestRedisClusterCache(t *testing.T) {
139 c := newRedisClusterCache()

Callers

nothing calls this directly

Calls 9

Uint64ToStrFunction · 0.92
newRedisCacheFunction · 0.85
CloseMethod · 0.65
SetMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65
MultiSetMethod · 0.65
MultiGetMethod · 0.65
DelMethod · 0.65

Tested by

no test coverage detected