(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestKeyExpirationWhileFetchtingRedis(t *testing.T) { |
| 145 | cache, redis := getRedisCacheAndServer(t) |
| 146 | defer cache.Close() |
| 147 | |
| 148 | key := &Key{ |
| 149 | Query: []byte(fmt.Sprintf("SELECT test")), |
| 150 | } |
| 151 | payloadSize := 4 * 1024 * 1024 |
| 152 | exepctedValue := strings.Repeat("a", payloadSize) |
| 153 | reader := strings.NewReader(exepctedValue) |
| 154 | |
| 155 | if _, err := cache.Put(reader, ContentMetadata{Encoding: "ce", Type: "ct", Length: int64(payloadSize)}, key); err != nil { |
| 156 | t.Fatalf("failed to put it to cache: %s", err) |
| 157 | } |
| 158 | cachedData, err := cache.Get(key) |
| 159 | if err != nil { |
| 160 | t.Fatalf("failed to get data from redis cache: %s", err) |
| 161 | } |
| 162 | |
| 163 | //simulating a cache expiration |
| 164 | if !redis.Del(key.String()) { |
| 165 | t.Fatalf("could not delete key") |
| 166 | } |
| 167 | _, err = io.ReadAll(cachedData.Data) |
| 168 | _, isRedisCacheError := err.(*RedisCacheError) |
| 169 | if err == nil || !isRedisCacheError { |
| 170 | t.Fatalf("expecting an error of type RedisCacheError, err=%s", err) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | func TestCorruptedPayloadWhileFetchtingRedis(t *testing.T) { |
| 175 | cache, redis := getRedisCacheAndServer(t) |
nothing calls this directly
no test coverage detected