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

Method fromEnv

acceptance/acceptance_test.go:620–662  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

618}
619
620func (e *testScriptEnv) fromEnv() error {
621 envMap := map[string]string{}
622
623 requiredEnvVars := []string{
624 "GH_ACCEPTANCE_HOST",
625 "GH_ACCEPTANCE_ORG",
626 "GH_ACCEPTANCE_TOKEN",
627 }
628
629 var missingEnvs []string
630 for _, key := range requiredEnvVars {
631 val, ok := os.LookupEnv(key)
632 if val == "" || !ok {
633 missingEnvs = append(missingEnvs, key)
634 continue
635 }
636
637 envMap[key] = val
638 }
639
640 if len(missingEnvs) > 0 {
641 return missingEnvError{missingEnvs: missingEnvs}
642 }
643
644 if envMap["GH_ACCEPTANCE_ORG"] == "github" || envMap["GH_ACCEPTANCE_ORG"] == "cli" {
645 return fmt.Errorf("GH_ACCEPTANCE_ORG cannot be 'github' or 'cli'")
646 }
647
648 e.host = envMap["GH_ACCEPTANCE_HOST"]
649 e.org = envMap["GH_ACCEPTANCE_ORG"]
650 e.token = envMap["GH_ACCEPTANCE_TOKEN"]
651
652 e.scripts = parseScriptFilter(os.Getenv("GH_ACCEPTANCE_SCRIPT"))
653 e.preserveWorkDir = os.Getenv("GH_ACCEPTANCE_PRESERVE_WORK_DIR") == "true"
654 e.skipDefer = os.Getenv("GH_ACCEPTANCE_SKIP_DEFER") == "true"
655 e.apiHost = os.Getenv("GH_ACCEPTANCE_API_HOST")
656 e.user = os.Getenv("GH_ACCEPTANCE_USER")
657 if e.apiHost != "" && e.user == "" {
658 return fmt.Errorf("GH_ACCEPTANCE_USER is required when GH_ACCEPTANCE_API_HOST is set")
659 }
660
661 return nil
662}
663
664func TestSkills(t *testing.T) {
665 var tsEnv testScriptEnv

Callers 15

TestAPIFunction · 0.95
TestAuthFunction · 0.95
TestGistsFunction · 0.95
TestGPGKeysFunction · 0.95
TestExtensionsFunction · 0.95
TestIssuesFunction · 0.95
TestDiscussionsFunction · 0.95
TestIssues2_0Function · 0.95
TestLabelsFunction · 0.95
TestOrgFunction · 0.95
TestProjectFunction · 0.95
TestPullRequestsFunction · 0.95

Calls 2

parseScriptFilterFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected