CI jobs have no $USER, fix tests
This commit is contained in:
20
env_test.go
20
env_test.go
@@ -7,17 +7,31 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestEnvironment(t *testing.T) {
|
func TestEnvironment(t *testing.T) {
|
||||||
|
key := "USER"
|
||||||
|
if testInPipeline() {
|
||||||
|
key = "CI"
|
||||||
|
}
|
||||||
|
|
||||||
testProvider(t, Environment(),
|
testProvider(t, Environment(),
|
||||||
testProviderCase{
|
testProviderCase{
|
||||||
Key: "USER",
|
Key: key,
|
||||||
Test: testNotEmpty,
|
Test: testNotEmpty,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEnvironmentPrefix(t *testing.T) {
|
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{
|
testProviderCase{
|
||||||
Key: "ER",
|
Key: key,
|
||||||
Test: testNotEmpty,
|
Test: testNotEmpty,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -63,3 +64,7 @@ func testEqual(a []byte) func([]byte) error {
|
|||||||
func testEqualString(a string) func([]byte) error {
|
func testEqualString(a string) func([]byte) error {
|
||||||
return testEqual([]byte(a))
|
return testEqual([]byte(a))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testInPipeline() bool {
|
||||||
|
return os.Getenv("CI") != ""
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user