mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Increase coverage in pkg/util/env to 100%
This commit is contained in:
parent
e7b92b9d0a
commit
9ba5f5869d
12
pkg/util/env/env_test.go
vendored
12
pkg/util/env/env_test.go
vendored
@ -50,6 +50,12 @@ func TestGetEnvAsIntOrFallback(t *testing.T) {
|
||||
key = "FLOCKER_UNSET_VAR"
|
||||
returnVal, _ = GetEnvAsIntOrFallback(key, expected)
|
||||
assert.Equal(expected, returnVal)
|
||||
|
||||
key = "FLOCKER_SET_VAR"
|
||||
os.Setenv(key, "not-an-int")
|
||||
returnVal, err := GetEnvAsIntOrFallback(key, 1)
|
||||
assert.Equal(expected, returnVal)
|
||||
assert.EqualError(err, "strconv.ParseInt: parsing \"not-an-int\": invalid syntax")
|
||||
}
|
||||
|
||||
func TestGetEnvAsFloat64OrFallback(t *testing.T) {
|
||||
@ -65,4 +71,10 @@ func TestGetEnvAsFloat64OrFallback(t *testing.T) {
|
||||
key = "FLOCKER_UNSET_VAR"
|
||||
returnVal, _ = GetEnvAsFloat64OrFallback(key, 1.0)
|
||||
assert.Equal(expected, returnVal)
|
||||
|
||||
key = "FLOCKER_SET_VAR"
|
||||
os.Setenv(key, "not-a-float")
|
||||
returnVal, err := GetEnvAsFloat64OrFallback(key, 1.0)
|
||||
assert.Equal(expected, returnVal)
|
||||
assert.EqualError(err, "strconv.ParseFloat: parsing \"not-a-float\": invalid syntax")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user