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

Method fromEnv

acceptance/acceptance_test.go:570–607  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

568}
569
570func (e *testScriptEnv) fromEnv() error {
571 envMap := map[string]string{}
572
573 requiredEnvVars := []string{
574 "GH_ACCEPTANCE_HOST",
575 "GH_ACCEPTANCE_ORG",
576 "GH_ACCEPTANCE_TOKEN",
577 }
578
579 var missingEnvs []string
580 for _, key := range requiredEnvVars {
581 val, ok := os.LookupEnv(key)
582 if val == "" || !ok {
583 missingEnvs = append(missingEnvs, key)
584 continue
585 }
586
587 envMap[key] = val
588 }
589
590 if len(missingEnvs) > 0 {
591 return missingEnvError{missingEnvs: missingEnvs}
592 }
593
594 if envMap["GH_ACCEPTANCE_ORG"] == "github" || envMap["GH_ACCEPTANCE_ORG"] == "cli" {
595 return fmt.Errorf("GH_ACCEPTANCE_ORG cannot be 'github' or 'cli'")
596 }
597
598 e.host = envMap["GH_ACCEPTANCE_HOST"]
599 e.org = envMap["GH_ACCEPTANCE_ORG"]
600 e.token = envMap["GH_ACCEPTANCE_TOKEN"]
601
602 e.script = os.Getenv("GH_ACCEPTANCE_SCRIPT")
603 e.preserveWorkDir = os.Getenv("GH_ACCEPTANCE_PRESERVE_WORK_DIR") == "true"
604 e.skipDefer = os.Getenv("GH_ACCEPTANCE_SKIP_DEFER") == "true"
605
606 return nil
607}
608
609func TestSkills(t *testing.T) {
610 var tsEnv testScriptEnv

Callers 15

TestAPIFunction · 0.95
TestAuthFunction · 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
TestReleasesFunction · 0.95

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected