test(inputs.disk): Set label in test to avoid reading local value (#15507)

This commit is contained in:
Joshua Powers 2024-06-13 11:44:44 -06:00 committed by GitHub
parent a17713e413
commit d7f3a0e2d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 11 additions and 1 deletions

View File

@ -571,6 +571,7 @@ func TestDiskUsageIssues(t *testing.T) {
map[string]string{
"device": "sda1",
"fstype": "ext4",
"label": "root",
"mode": "rw",
"path": "/",
},
@ -592,6 +593,7 @@ func TestDiskUsageIssues(t *testing.T) {
map[string]string{
"device": "sdb",
"fstype": "ext4",
"label": "storage",
"mode": "rw",
"path": "/mnt/storage",
},
@ -616,12 +618,18 @@ func TestDiskUsageIssues(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
// Setup the environment
hostMountPrefix := tt.prefix
hostProcPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_")))
hostProcPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_"), "proc"))
require.NoError(t, err)
hostSysPrefix, err := filepath.Abs(filepath.Join("testdata", strings.ReplaceAll(tt.name, " ", "_"), "sys"))
require.NoError(t, err)
// Get the partitions in the test-case
os.Clearenv()
t.Setenv("HOST_PROC", hostProcPrefix)
t.Setenv("HOST_SYS", hostSysPrefix)
partitions, err := diskUtil.Partitions(true)
require.NoError(t, err)

View File

@ -0,0 +1 @@
root

View File

@ -0,0 +1 @@
storage