TestSaveConfigFallback verifies that saveConfig succeeds via a fallback directory when $HOME/.thunder is not usable, so agents running in sandboxes with read-only HOME don't hit a hard failure.
(t *testing.T)
| 256 | // directory when $HOME/.thunder is not usable, so agents running in |
| 257 | // sandboxes with read-only HOME don't hit a hard failure. |
| 258 | func TestSaveConfigFallback(t *testing.T) { |
| 259 | tmpDir := t.TempDir() |
| 260 | |
| 261 | // Block $HOME/.thunder by putting a file there. |
| 262 | require.NoError(t, os.WriteFile(filepath.Join(tmpDir, ".thunder"), []byte("x"), 0600)) |
| 263 | |
| 264 | t.Setenv("HOME", tmpDir) |
| 265 | t.Setenv("XDG_CACHE_HOME", filepath.Join(tmpDir, "cache")) |
| 266 | t.Setenv("TNR_HOME", "") |
| 267 | |
| 268 | require.NoError(t, saveConfig(AuthResponse{Token: "test_token"})) |
| 269 | |
| 270 | // Config must have landed in the UserCacheDir fallback, not under $HOME/.thunder. |
| 271 | cacheBase, err := os.UserCacheDir() |
| 272 | require.NoError(t, err) |
| 273 | assert.FileExists(t, filepath.Join(cacheBase, "thunder", "cli_config.json")) |
| 274 | } |
| 275 | |
| 276 | // TestLoginCommandTableDriven provides comprehensive test coverage for various |
| 277 | // authentication scenarios including successful logins with and without expiration. |
nothing calls this directly
no test coverage detected