(t *testing.T)
| 426 | } |
| 427 | |
| 428 | func 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 | |
| 485 | func tempFilePath() string { |
nothing calls this directly
no test coverage detected