test(inputs.disk): Set label in test to avoid reading local value (#15507)
This commit is contained in:
parent
a17713e413
commit
d7f3a0e2d9
|
|
@ -571,6 +571,7 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "sda1",
|
"device": "sda1",
|
||||||
"fstype": "ext4",
|
"fstype": "ext4",
|
||||||
|
"label": "root",
|
||||||
"mode": "rw",
|
"mode": "rw",
|
||||||
"path": "/",
|
"path": "/",
|
||||||
},
|
},
|
||||||
|
|
@ -592,6 +593,7 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
map[string]string{
|
map[string]string{
|
||||||
"device": "sdb",
|
"device": "sdb",
|
||||||
"fstype": "ext4",
|
"fstype": "ext4",
|
||||||
|
"label": "storage",
|
||||||
"mode": "rw",
|
"mode": "rw",
|
||||||
"path": "/mnt/storage",
|
"path": "/mnt/storage",
|
||||||
},
|
},
|
||||||
|
|
@ -616,12 +618,18 @@ func TestDiskUsageIssues(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// Setup the environment
|
// Setup the environment
|
||||||
hostMountPrefix := tt.prefix
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Get the partitions in the test-case
|
// Get the partitions in the test-case
|
||||||
os.Clearenv()
|
os.Clearenv()
|
||||||
t.Setenv("HOST_PROC", hostProcPrefix)
|
t.Setenv("HOST_PROC", hostProcPrefix)
|
||||||
|
t.Setenv("HOST_SYS", hostSysPrefix)
|
||||||
|
|
||||||
partitions, err := diskUtil.Partitions(true)
|
partitions, err := diskUtil.Partitions(true)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
root
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
storage
|
||||||
Loading…
Reference in New Issue