From d2d184b8eada222c8f1cf9c850bae34feb6e08d7 Mon Sep 17 00:00:00 2001 From: Brian Hnat Date: Tue, 19 Jul 2022 22:16:36 -0400 Subject: [PATCH] the environment variables already present while running in github actions had to be accounted for in the tests (#150) --- go/detect_environment.go | 2 -- go/detect_environment_test.go | 9 +++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/go/detect_environment.go b/go/detect_environment.go index 44947139..8b09b2d4 100644 --- a/go/detect_environment.go +++ b/go/detect_environment.go @@ -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) diff --git a/go/detect_environment_test.go b/go/detect_environment_test.go index 1a3fafc7..f2d733e8 100644 --- a/go/detect_environment_test.go +++ b/go/detect_environment_test.go @@ -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) }