Skip to content

Commit

Permalink
the environment variables already present while running in github act…
Browse files Browse the repository at this point in the history
…ions had to be accounted for in the tests (#150)
  • Loading branch information
dumpsterfireproject committed Jul 20, 2022
1 parent 17c70d8 commit d2d184b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions go/detect_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ func evalutate(expression string) (string, error) {
case *variableExpression:
s, err := t.Evaluate()
if err != nil {
l := log.New(os.Stderr, "", 0)
l.Printf("error evalutating %s: %s", expression, err)
return result, err
}
result = fmt.Sprintf("%s%s", result, s)
Expand Down
9 changes: 9 additions & 0 deletions go/detect_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ func TestDetectCIEnvironment(t *testing.T) {

func testDetectCIEnvironment(envVars map[string]string, want *cienvironment.CiEnvironment) func(*testing.T) {
return func(t *testing.T) {
// when running on github, unset the variables already present there for this test execution
t.Setenv("GITHUB_SERVER_URL", "")
t.Setenv("GITHUB_REPOSITORY", "")
t.Setenv("GITHUB_RUN_ID", "")
t.Setenv("GITHUB_SHA", "")
t.Setenv("GITHUB_HEAD_REF", "")
t.Setenv("GITHUB_EVENT_NAME", "")
t.Setenv("GITHUB_EVENT_PATH", "")
// set the environment variables per the .txt file in the testdata directory
for k, v := range envVars {
t.Setenv(k, v)
}
Expand Down

0 comments on commit d2d184b

Please sign in to comment.