withTempCacheDir points the detection cache at an isolated temp directory for the test and restores the original value on cleanup.
(t *testing.T)
| 11 | // withTempCacheDir points the detection cache at an isolated temp directory |
| 12 | // for the test and restores the original value on cleanup. |
| 13 | func withTempCacheDir(t *testing.T) string { |
| 14 | t.Helper() |
| 15 | dir := t.TempDir() |
| 16 | previous := os.Getenv("CAM_CACHE_DIR") |
| 17 | os.Setenv("CAM_CACHE_DIR", dir) |
| 18 | t.Cleanup(func() { os.Setenv("CAM_CACHE_DIR", previous) }) |
| 19 | return dir |
| 20 | } |
| 21 | |
| 22 | func TestDetectionCacheGetMissing(t *testing.T) { |
| 23 | cache := newDetectionCache() |
no outgoing calls
no test coverage detected