66 "time"
77)
88
9+ const testValue1 = "value1"
10+
911func TestCacheKeys (t * testing.T ) {
1012 cache , err := New (NewDefaultConfig ())
1113 if err != nil {
@@ -19,7 +21,7 @@ func TestCacheKeys(t *testing.T) {
1921 }
2022
2123 // Add some entries
22- _ = cache .Set ("key1" , "value1" , time .Hour )
24+ _ = cache .Set ("key1" , testValue1 , time .Hour )
2325 _ = cache .Set ("key2" , "value2" , time .Hour )
2426 _ = cache .Set ("key3" , "value3" , time .Hour )
2527
@@ -54,7 +56,7 @@ func TestCacheLen(t *testing.T) {
5456 }
5557
5658 // Add some entries
57- _ = cache .Set ("key1" , "value1" , time .Hour )
59+ _ = cache .Set ("key1" , testValue1 , time .Hour )
5860 if cache .Len () != 1 {
5961 t .Fatalf ("Expected length 1, got %d" , cache .Len ())
6062 }
@@ -83,7 +85,7 @@ func TestCacheHas(t *testing.T) {
8385 }
8486
8587 // Add an entry
86- _ = cache .Set ("key1" , "value1" , time .Hour )
88+ _ = cache .Set ("key1" , testValue1 , time .Hour )
8789
8890 if ! cache .Has ("key1" ) {
8991 t .Fatal ("Cache should have key1" )
@@ -124,7 +126,7 @@ func TestCacheTTLMethod(t *testing.T) {
124126 if ! found {
125127 t .Fatal ("Should find existing key" )
126128 }
127- if value != "value1" {
129+ if value != testValue1 {
128130 t .Fatalf ("Expected value1, got %v" , value )
129131 }
130132
@@ -163,7 +165,7 @@ func TestCacheClear(t *testing.T) {
163165 }
164166
165167 // Add multiple entries
166- _ = cache .Set ("key1" , "value1" , time .Hour )
168+ _ = cache .Set ("key1" , testValue1 , time .Hour )
167169 _ = cache .Set ("key2" , "value2" , time .Hour )
168170 _ = cache .Set ("key3" , "value3" , time .Hour )
169171
@@ -192,7 +194,7 @@ func TestCacheClose(t *testing.T) {
192194 }
193195
194196 // Add an entry
195- _ = cache .Set ("key1" , "value1" , time .Hour )
197+ _ = cache .Set ("key1" , testValue1 , time .Hour )
196198
197199 // Close should not error
198200 _ = cache .Close () // Test cleanup
@@ -254,7 +256,7 @@ func TestCacheClearWithHooks(t *testing.T) {
254256 }
255257
256258 // Add multiple entries
257- _ = cache .Set ("key1" , "value1" , time .Hour )
259+ _ = cache .Set ("key1" , testValue1 , time .Hour )
258260 _ = cache .Set ("key2" , "value2" , time .Hour )
259261
260262 // Invalidate all should trigger hooks
0 commit comments