github.com/hernad/nomad@v1.6.112/command/agent/host/host_test.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package host 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/require" 10 ) 11 12 func TestHostUtils(t *testing.T) { 13 mounts := mountedPaths() 14 require.NotEmpty(t, mounts) 15 16 du, err := diskUsage("/") 17 require.NoError(t, err) 18 require.NotZero(t, du.DiskMB) 19 require.NotZero(t, du.UsedMB) 20 } 21 22 func TestMakeHostData(t *testing.T) { 23 24 t.Setenv("VAULT_TOKEN", "foo") 25 t.Setenv("BOGUS_TOKEN", "foo") 26 t.Setenv("BOGUS_SECRET", "foo") 27 t.Setenv("ryanSECRETS", "foo") 28 29 host, err := MakeHostData() 30 require.NoError(t, err) 31 require.NotEmpty(t, host.OS) 32 require.NotEmpty(t, host.Network) 33 require.NotEmpty(t, host.ResolvConf) 34 require.NotEmpty(t, host.Hosts) 35 require.NotEmpty(t, host.Disk) 36 require.NotEmpty(t, host.Environment) 37 require.Equal(t, "<redacted>", host.Environment["VAULT_TOKEN"]) 38 require.Equal(t, "<redacted>", host.Environment["BOGUS_TOKEN"]) 39 require.Equal(t, "<redacted>", host.Environment["BOGUS_SECRET"]) 40 require.Equal(t, "<redacted>", host.Environment["ryanSECRETS"]) 41 }