diff --git a/env_test.go b/env_test.go index b6d4a3c..59dd8f5 100644 --- a/env_test.go +++ b/env_test.go @@ -7,17 +7,31 @@ import ( ) func TestEnvironment(t *testing.T) { + key := "USER" + if testInPipeline() { + key = "CI" + } + testProvider(t, Environment(), testProviderCase{ - Key: "USER", + Key: key, Test: testNotEmpty, }) } func TestEnvironmentPrefix(t *testing.T) { - testProvider(t, EnvironmentPrefix("US"), + var ( + prefix = "US" + key = "ER" + ) + if testInPipeline() { + prefix = "CI_" + key = "JOB_ID" + } + + testProvider(t, EnvironmentPrefix(prefix), testProviderCase{ - Key: "ER", + Key: key, Test: testNotEmpty, }) } diff --git a/provider_test.go b/provider_test.go index 57893fc..9c464b7 100644 --- a/provider_test.go +++ b/provider_test.go @@ -4,6 +4,7 @@ import ( "bytes" "errors" "fmt" + "os" "testing" ) @@ -63,3 +64,7 @@ func testEqual(a []byte) func([]byte) error { func testEqualString(a string) func([]byte) error { return testEqual([]byte(a)) } + +func testInPipeline() bool { + return os.Getenv("CI") != "" +}