MCPcopy Create free account
hub / github.com/cli/cli / Test_mightBeGHESUser

Function Test_mightBeGHESUser

internal/ghcmd/cmd_test.go:445–516  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

443}
444
445func Test_mightBeGHESUser(t *testing.T) {
446 tests := []struct {
447 name string
448 env map[string]string
449 cfgString string
450 want bool
451 }{
452 {
453 name: "GH_ENTERPRISE_TOKEN set",
454 env: map[string]string{"GH_ENTERPRISE_TOKEN": "some-token"},
455 want: true,
456 },
457 {
458 name: "GITHUB_ENTERPRISE_TOKEN set",
459 env: map[string]string{"GITHUB_ENTERPRISE_TOKEN": "some-token"},
460 want: true,
461 },
462 {
463 name: "no env vars, config has enterprise host",
464 cfgString: "hosts:\n ghes.example.com:\n oauth_token: abc123\n",
465 want: true,
466 },
467 {
468 name: "no env vars, config has only github.com",
469 cfgString: "hosts:\n github.com:\n oauth_token: abc123\n",
470 want: false,
471 },
472 {
473 name: "no env vars, config has no hosts",
474 want: false,
475 },
476 {
477 name: "no env vars, config has github.com and enterprise host",
478 cfgString: "hosts:\n github.com:\n oauth_token: abc123\n ghes.example.com:\n oauth_token: def456\n",
479 want: true,
480 },
481 {
482 name: "no env vars, config has tenancy host",
483 cfgString: "hosts:\n my-company.ghe.com:\n oauth_token: abc123\n",
484 want: false,
485 },
486 {
487 name: "GH_HOST set to enterprise host",
488 env: map[string]string{"GH_HOST": "ghes.example.com"},
489 want: true,
490 },
491 {
492 name: "GH_HOST set to github.com",
493 env: map[string]string{"GH_HOST": "github.com"},
494 want: false,
495 },
496 {
497 name: "GH_HOST set to tenancy host",
498 env: map[string]string{"GH_HOST": "my-company.ghe.com"},
499 want: false,
500 },
501 }
502

Callers

nothing calls this directly

Calls 4

NewIsolatedTestConfigFunction · 0.92
mightBeGHESUserFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected