MCPcopy Create free account
hub / github.com/github/gh-aw / TestCheckForUpdatesInCIMode

Function TestCheckForUpdatesInCIMode

pkg/cli/update_check_test.go:273–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

271}
272
273func TestCheckForUpdatesInCIMode(t *testing.T) {
274 // Save original environment and function
275 origCI := os.Getenv("CI")
276 origGetLastCheckFilePath := getLastCheckFilePathFunc
277 defer func() {
278 os.Setenv("CI", origCI)
279 getLastCheckFilePathFunc = origGetLastCheckFilePath
280 }()
281
282 // Set CI environment
283 os.Setenv("CI", "true")
284
285 // Create temporary directory for last check file
286 tmpDir := t.TempDir()
287 lastCheckFile := filepath.Join(tmpDir, lastCheckFileName)
288
289 // Override the function to use temp directory
290 getLastCheckFilePathFunc = func() string {
291 return lastCheckFile
292 }
293
294 // Call checkForUpdates
295 checkForUpdates(false, false)
296
297 // Verify that no last check file was created (since check was skipped in CI)
298 if _, err := os.Stat(lastCheckFile); err == nil {
299 t.Error("Last check file should not be created in CI mode")
300 }
301}
302
303func TestCheckForUpdatesAsync_ContextCancellation(t *testing.T) {
304 // Test that async update check respects context cancellation

Callers

nothing calls this directly

Calls 4

checkForUpdatesFunction · 0.85
GetenvMethod · 0.80
SetenvMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected