MCPcopy Index your code
hub / github.com/cli/cli / TestShouldCheckForExtensionUpdate

Function TestShouldCheckForExtensionUpdate

internal/update/update_test.go:428–483  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

426}
427
428func TestShouldCheckForExtensionUpdate(t *testing.T) {
429 tests := []struct {
430 name string
431 env map[string]string
432 expected bool
433 }{
434 {
435 name: "should not check when user has explicitly disable notifications",
436 env: map[string]string{
437 "GH_NO_EXTENSION_UPDATE_NOTIFIER": "1",
438 },
439 expected: false,
440 },
441 {
442 name: "should not check when user is in codespace",
443 env: map[string]string{
444 "CODESPACES": "1",
445 },
446 expected: false,
447 },
448 {
449 name: "should not check when in GitHub Actions / Travis / Circle / Cirrus / GitLab / AppVeyor / CodeShip / dsari",
450 env: map[string]string{
451 "CI": "1",
452 },
453 expected: false,
454 },
455 {
456 name: "should not check when in Jenkins / TeamCity",
457 env: map[string]string{
458 "BUILD_NUMBER": "1",
459 },
460 expected: false,
461 },
462 {
463 name: "should not check when in TaskCluster / dsari",
464 env: map[string]string{
465 "RUN_ID": "1",
466 },
467 expected: false,
468 },
469 // TODO: Figure out how to refactor IsTerminal() to be testable
470 }
471
472 for _, tt := range tests {
473 t.Run(tt.name, func(t *testing.T) {
474 os.Clearenv()
475 for k, v := range tt.env {
476 os.Setenv(k, v)
477 }
478
479 actual := ShouldCheckForExtensionUpdate()
480 require.Equal(t, tt.expected, actual)
481 })
482 }
483}
484
485func tempFilePath() string {

Callers

nothing calls this directly

Calls 3

EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected