From 8f5783d1c21f058d75831a1183dba955e4cafdca Mon Sep 17 00:00:00 2001 From: Pierre Gimalac Date: Wed, 18 Sep 2024 15:14:27 +0200 Subject: [PATCH] [ASCII-2294] Add suffix to fstype to avoid using a real type (#29371) --- pkg/gohai/filesystem/filesystem_nix.go | 4 +--- pkg/gohai/filesystem/filesystem_nix_test.go | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/gohai/filesystem/filesystem_nix.go b/pkg/gohai/filesystem/filesystem_nix.go index f25f6adc97d3e..27f5094d1e282 100644 --- a/pkg/gohai/filesystem/filesystem_nix.go +++ b/pkg/gohai/filesystem/filesystem_nix.go @@ -74,9 +74,7 @@ func replaceDev(oldMount, newMount MountInfo) bool { } // getFileSystemInfoWithMounts is an internal method to help testing with test mounts and mocking syscalls -func getFileSystemInfoWithMounts(initialMounts []*mountinfo.Info, sizeKB, dev fsInfoGetter) ([]MountInfo, error) { - mounts := initialMounts - +func getFileSystemInfoWithMounts(mounts []*mountinfo.Info, sizeKB, dev fsInfoGetter) ([]MountInfo, error) { devMountInfos := map[uint64]MountInfo{} for _, mount := range mounts { // Skip mounts that seem to be missing data diff --git a/pkg/gohai/filesystem/filesystem_nix_test.go b/pkg/gohai/filesystem/filesystem_nix_test.go index c41b7c369110d..55a7c92563370 100644 --- a/pkg/gohai/filesystem/filesystem_nix_test.go +++ b/pkg/gohai/filesystem/filesystem_nix_test.go @@ -117,7 +117,6 @@ func TestNixFSTypeFiltering(t *testing.T) { mounts, err := getFileSystemInfoWithMounts(inputMounts, mockFSSizeKB, getMockFSDev()) require.NoError(t, err) - require.Equal(t, len(expectedMounts), len(mounts)) assert.ElementsMatch(t, mounts, expectedMounts) }) } @@ -260,8 +259,9 @@ func TestFilterDev(t *testing.T) { func newTestInputMountinfo(name string) *mountinfo.Info { return &mountinfo.Info{ + // add suffixes to the name to avoid having an ignored source / type / mountpoint Source: name + "Source", - FSType: name, + FSType: name + "Type", Mountpoint: name + "MountPoint", } }