(t *testing.T)
| 220 | } |
| 221 | |
| 222 | func TestCheckForUpdatesWithNoCheckUpdateFlag(t *testing.T) { |
| 223 | // This test verifies that checkForUpdates respects the noCheckUpdate flag |
| 224 | // and doesn't make any API calls when the flag is true |
| 225 | |
| 226 | // Save original environment and function |
| 227 | origCI := os.Getenv("CI") |
| 228 | origGithubActions := os.Getenv("GITHUB_ACTIONS") |
| 229 | origContinuousIntegration := os.Getenv("CONTINUOUS_INTEGRATION") |
| 230 | origGetLastCheckFilePath := getLastCheckFilePathFunc |
| 231 | defer func() { |
| 232 | if origCI != "" { |
| 233 | os.Setenv("CI", origCI) |
| 234 | } else { |
| 235 | os.Unsetenv("CI") |
| 236 | } |
| 237 | if origGithubActions != "" { |
| 238 | os.Setenv("GITHUB_ACTIONS", origGithubActions) |
| 239 | } else { |
| 240 | os.Unsetenv("GITHUB_ACTIONS") |
| 241 | } |
| 242 | if origContinuousIntegration != "" { |
| 243 | os.Setenv("CONTINUOUS_INTEGRATION", origContinuousIntegration) |
| 244 | } else { |
| 245 | os.Unsetenv("CONTINUOUS_INTEGRATION") |
| 246 | } |
| 247 | getLastCheckFilePathFunc = origGetLastCheckFilePath |
| 248 | }() |
| 249 | |
| 250 | // Ensure we're not in CI mode |
| 251 | os.Unsetenv("CI") |
| 252 | os.Unsetenv("GITHUB_ACTIONS") |
| 253 | os.Unsetenv("CONTINUOUS_INTEGRATION") |
| 254 | |
| 255 | // Create temporary directory for last check file |
| 256 | tmpDir := t.TempDir() |
| 257 | lastCheckFile := filepath.Join(tmpDir, lastCheckFileName) |
| 258 | |
| 259 | // Override the function to use temp directory |
| 260 | getLastCheckFilePathFunc = func() string { |
| 261 | return lastCheckFile |
| 262 | } |
| 263 | |
| 264 | // Call checkForUpdates with noCheckUpdate=true |
| 265 | checkForUpdates(true, false) |
| 266 | |
| 267 | // Verify that no last check file was created (since check was skipped) |
| 268 | if _, err := os.Stat(lastCheckFile); err == nil { |
| 269 | t.Error("Last check file should not be created when noCheckUpdate=true") |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | func TestCheckForUpdatesInCIMode(t *testing.T) { |
| 274 | // Save original environment and function |
nothing calls this directly
no test coverage detected