(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestSetupGHCommandUsesDefaultGHHost(t *testing.T) { |
| 478 | originalDefaultHost := getDefaultGHHost() |
| 479 | defer SetDefaultGHHost(originalDefaultHost) |
| 480 | |
| 481 | t.Run("applies default host when GH_HOST is not set", func(t *testing.T) { |
| 482 | originalHost, hadOriginalHost := os.LookupEnv("GH_HOST") |
| 483 | require.NoError(t, os.Unsetenv("GH_HOST")) |
| 484 | t.Cleanup(func() { |
| 485 | if hadOriginalHost { |
| 486 | require.NoError(t, os.Setenv("GH_HOST", originalHost)) |
| 487 | return |
| 488 | } |
| 489 | require.NoError(t, os.Unsetenv("GH_HOST")) |
| 490 | }) |
| 491 | SetDefaultGHHost("myorg.ghe.com") |
| 492 | |
| 493 | cmd := setupGHCommand(context.Background(), "auth", "status") |
| 494 | require.NotNil(t, cmd.Env) |
| 495 | assert.Contains(t, cmd.Env, "GH_HOST=myorg.ghe.com") |
| 496 | }) |
| 497 | |
| 498 | t.Run("does not apply default host when GH_HOST is already set", func(t *testing.T) { |
| 499 | t.Setenv("GH_HOST", "explicit.ghe.com") |
| 500 | SetDefaultGHHost("myorg.ghe.com") |
| 501 | |
| 502 | cmd := setupGHCommand(context.Background(), "auth", "status") |
| 503 | if cmd.Env == nil { |
| 504 | return |
| 505 | } |
| 506 | assert.NotContains(t, cmd.Env, "GH_HOST=myorg.ghe.com") |
| 507 | }) |
| 508 | } |
nothing calls this directly
no test coverage detected