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

Function TestSetupGHCommandUsesDefaultGHHost

pkg/workflow/github_cli_test.go:477–508  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

475}
476
477func 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}

Callers

nothing calls this directly

Calls 6

SetenvMethod · 0.80
BackgroundMethod · 0.80
getDefaultGHHostFunction · 0.70
SetDefaultGHHostFunction · 0.70
setupGHCommandFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected