(t *testing.T)
| 369 | } |
| 370 | |
| 371 | func TestShouldCheckForUpdate(t *testing.T) { |
| 372 | tests := []struct { |
| 373 | name string |
| 374 | env map[string]string |
| 375 | expected bool |
| 376 | }{ |
| 377 | { |
| 378 | name: "should not check when user has explicitly disable notifications", |
| 379 | env: map[string]string{ |
| 380 | "GH_NO_UPDATE_NOTIFIER": "1", |
| 381 | }, |
| 382 | expected: false, |
| 383 | }, |
| 384 | { |
| 385 | name: "should not check when user is in codespace", |
| 386 | env: map[string]string{ |
| 387 | "CODESPACES": "1", |
| 388 | }, |
| 389 | expected: false, |
| 390 | }, |
| 391 | { |
| 392 | name: "should not check when in GitHub Actions / Travis / Circle / Cirrus / GitLab / AppVeyor / CodeShip / dsari", |
| 393 | env: map[string]string{ |
| 394 | "CI": "1", |
| 395 | }, |
| 396 | expected: false, |
| 397 | }, |
| 398 | { |
| 399 | name: "should not check when in Jenkins / TeamCity", |
| 400 | env: map[string]string{ |
| 401 | "BUILD_NUMBER": "1", |
| 402 | }, |
| 403 | expected: false, |
| 404 | }, |
| 405 | { |
| 406 | name: "should not check when in TaskCluster / dsari", |
| 407 | env: map[string]string{ |
| 408 | "RUN_ID": "1", |
| 409 | }, |
| 410 | expected: false, |
| 411 | }, |
| 412 | // TODO: Figure out how to refactor IsTerminal() to be testable |
| 413 | } |
| 414 | |
| 415 | for _, tt := range tests { |
| 416 | t.Run(tt.name, func(t *testing.T) { |
| 417 | os.Clearenv() |
| 418 | for k, v := range tt.env { |
| 419 | os.Setenv(k, v) |
| 420 | } |
| 421 | |
| 422 | actual := ShouldCheckForUpdate() |
| 423 | require.Equal(t, tt.expected, actual) |
| 424 | }) |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | func TestShouldCheckForExtensionUpdate(t *testing.T) { |
nothing calls this directly
no test coverage detected