(t *testing.T)
| 23 | } |
| 24 | |
| 25 | func TestGetReturnsDataWhenSet(t *testing.T) { |
| 26 | cache := NewFileCache() |
| 27 | |
| 28 | key := randomKey() |
| 29 | expiry := time.Now().UTC().Add(time.Second * 30) |
| 30 | |
| 31 | cache.Set(key, "my-value", expiry) |
| 32 | value, expiresAt := cache.Get(key) |
| 33 | |
| 34 | if value != "my-value" { |
| 35 | t.Errorf("Should return data from cache, but got: %v", value) |
| 36 | } |
| 37 | if expiry.Unix() != expiresAt.Unix() { |
| 38 | t.Errorf("Should return expiry value %v, but got: %v", expiry.Unix(), expiresAt.Unix()) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func TestGetDoesNotReturnExpiredData(t *testing.T) { |
| 43 | cache := NewFileCache() |
nothing calls this directly
no test coverage detected