Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure folders do not get loaded more than once #10551

Merged
merged 16 commits into from
Feb 16, 2022
Merged
Prev Previous commit
Next Next commit
fix: check folders based on os
  • Loading branch information
MyaLongmire committed Feb 10, 2022
commit 73e26c6d1f9b6cd941fad2c09f29edaea2ceac9d
12 changes: 8 additions & 4 deletions internal/snmp/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,18 @@ func (t *TestingMibLoader) loadModule(path string) error {
}
func TestFolderLookup(t *testing.T) {
var folders []string
var givenPath []string

tests := []struct {
name string
mibPath []string
mibPath [][]string
paths [][]string
files []string
windowsFiles []string
}{
{
name: "loading folders",
mibPath: []string{"testdata/loadMibsFromPath"},
mibPath: [][]string{{"testdata", "loadMibsFromPath"}},
paths: [][]string{{"testdata", "loadMibsFromPath"}, {"testdata", "loadMibsFromPath", "linkTarget"}, {"testdata", "loadMibsFromPath", "root"}},
files: []string{"emptyFile"},
windowsFiles: []string{"emptyFile", "symlink"},
Expand All @@ -125,8 +126,11 @@ func TestFolderLookup(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
loader := TestingMibLoader{}

err := LoadMibsFromPath(tt.mibPath, testutil.Logger{}, &loader)
for _, paths := range tt.mibPath {
rootPath := filepath.Join(paths...)
givenPath = append(givenPath, rootPath)
}
err := LoadMibsFromPath(givenPath, testutil.Logger{}, &loader)
require.NoError(t, err)
for _, pathSlice := range tt.paths {
path := filepath.Join(pathSlice...)
Expand Down