added config struct for cache so we can change timeouts in testing

This commit is contained in:
2026-04-21 09:51:09 -06:00
parent e9f0a49077
commit b52df05565
3 changed files with 35 additions and 19 deletions
+4 -2
View File
@@ -22,7 +22,9 @@ func newTestServer(t *testing.T, handler http.HandlerFunc) *httptest.Server {
func newTestCache(t *testing.T, mirrorURL []string) *Cache {
t.Helper()
mirroredRepos := []string{"core", "extra"}
return NewCache(t.TempDir(), mirrorURL, mirroredRepos)
c := NewCache(t.TempDir(), mirrorURL, mirroredRepos)
c.client.Timeout = 500 * time.Millisecond
return c
}
func TestFetchFileExists(t *testing.T) {
@@ -39,7 +41,7 @@ func TestFetchFileExists(t *testing.T) {
t.Fatalf("Fetch failed %v", err)
}
fakefilepath := filepath.Join(c.cacheRoot, "fakefile")
fakefilepath := filepath.Join(c.cfg.cacheRoot, "fakefile")
data, err := os.ReadFile(fakefilepath)
if err != nil {