MCPcopy Index your code
hub / github.com/cli/cli / fromEnv

Method fromEnv

acceptance/acceptance_test.go:482–519  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

480}
481
482func (e *testScriptEnv) fromEnv() error {
483 envMap := map[string]string{}
484
485 requiredEnvVars := []string{
486 "GH_ACCEPTANCE_HOST",
487 "GH_ACCEPTANCE_ORG",
488 "GH_ACCEPTANCE_TOKEN",
489 }
490
491 var missingEnvs []string
492 for _, key := range requiredEnvVars {
493 val, ok := os.LookupEnv(key)
494 if val == "" || !ok {
495 missingEnvs = append(missingEnvs, key)
496 continue
497 }
498
499 envMap[key] = val
500 }
501
502 if len(missingEnvs) > 0 {
503 return missingEnvError{missingEnvs: missingEnvs}
504 }
505
506 if envMap["GH_ACCEPTANCE_ORG"] == "github" || envMap["GH_ACCEPTANCE_ORG"] == "cli" {
507 return fmt.Errorf("GH_ACCEPTANCE_ORG cannot be 'github' or 'cli'")
508 }
509
510 e.host = envMap["GH_ACCEPTANCE_HOST"]
511 e.org = envMap["GH_ACCEPTANCE_ORG"]
512 e.token = envMap["GH_ACCEPTANCE_TOKEN"]
513
514 e.script = os.Getenv("GH_ACCEPTANCE_SCRIPT")
515 e.preserveWorkDir = os.Getenv("GH_ACCEPTANCE_PRESERVE_WORK_DIR") == "true"
516 e.skipDefer = os.Getenv("GH_ACCEPTANCE_SKIP_DEFER") == "true"
517
518 return nil
519}
520
521func TestSkills(t *testing.T) {
522 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