cc9b480996
Neither the `os.Setenv` nor `t.Setenv` helper are safe to use in parallel tests because environment variables are process-global. The stdlib panics if you try to do this. Remove the `ci.Parallel()` call from all tests where we're setting environment variables.
39 lines
978 B
Go
39 lines
978 B
Go
package host
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestHostUtils(t *testing.T) {
|
|
mounts := mountedPaths()
|
|
require.NotEmpty(t, mounts)
|
|
|
|
du, err := diskUsage("/")
|
|
require.NoError(t, err)
|
|
require.NotZero(t, du.DiskMB)
|
|
require.NotZero(t, du.UsedMB)
|
|
}
|
|
|
|
func TestMakeHostData(t *testing.T) {
|
|
|
|
t.Setenv("VAULT_TOKEN", "foo")
|
|
t.Setenv("BOGUS_TOKEN", "foo")
|
|
t.Setenv("BOGUS_SECRET", "foo")
|
|
t.Setenv("ryanSECRETS", "foo")
|
|
|
|
host, err := MakeHostData()
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, host.OS)
|
|
require.NotEmpty(t, host.Network)
|
|
require.NotEmpty(t, host.ResolvConf)
|
|
require.NotEmpty(t, host.Hosts)
|
|
require.NotEmpty(t, host.Disk)
|
|
require.NotEmpty(t, host.Environment)
|
|
require.Equal(t, "<redacted>", host.Environment["VAULT_TOKEN"])
|
|
require.Equal(t, "<redacted>", host.Environment["BOGUS_TOKEN"])
|
|
require.Equal(t, "<redacted>", host.Environment["BOGUS_SECRET"])
|
|
require.Equal(t, "<redacted>", host.Environment["ryanSECRETS"])
|
|
}
|