(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestGetDoesNotReturnExpiredData(t *testing.T) { |
| 43 | cache := NewFileCache() |
| 44 | |
| 45 | key := randomKey() |
| 46 | cache.Set(key, "my-value", time.Now().UTC().Add(-time.Second)) |
| 47 | value, expiry := cache.Get(key) |
| 48 | |
| 49 | if value != "" { |
| 50 | t.Errorf("Should not return any data from cache, but got: %v", value) |
| 51 | } |
| 52 | zero := time.Time{} |
| 53 | if expiry != zero { |
| 54 | t.Errorf("Should not return expiry value, but got: %v", expiry) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func randomKey() string { |
| 59 | randBytes := make([]byte, 32) |
nothing calls this directly
no test coverage detected