diff --git a/version/update_test.go b/version/update_test.go index c6bcc32a9..f5b2e4f7c 100644 --- a/version/update_test.go +++ b/version/update_test.go @@ -7,10 +7,20 @@ import ( "net/url" "os" "path/filepath" + "runtime" "testing" "time" ) +func setHome(t *testing.T, dir string) { + t.Helper() + if runtime.GOOS == "windows" { + t.Setenv("USERPROFILE", dir) + } else { + t.Setenv("HOME", dir) + } +} + func TestCheckForUpdate(t *testing.T) { t.Run("update available", func(t *testing.T) { ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +80,7 @@ func TestCheckForUpdate(t *testing.T) { func TestCacheRoundTrip(t *testing.T) { tmp := t.TempDir() - t.Setenv("HOME", tmp) + setHome(t, tmp) os.MkdirAll(filepath.Join(tmp, ".ollama"), 0o755) if err := CacheAvailableUpdate(); err != nil { @@ -92,7 +102,7 @@ func TestCacheRoundTrip(t *testing.T) { func TestHasCachedUpdateStale(t *testing.T) { tmp := t.TempDir() - t.Setenv("HOME", tmp) + setHome(t, tmp) os.MkdirAll(filepath.Join(tmp, ".ollama"), 0o755) if err := CacheAvailableUpdate(); err != nil {