test(fs): add --skip-files, --skip-dirs (#2984)

This commit is contained in:
Hirotaka Tagawa / wafuwafu13
2022-10-12 21:20:56 +09:00
committed by GitHub
parent 561b2e7566
commit a8ff5f06b5
4 changed files with 309 additions and 1 deletions

View File

@@ -26,6 +26,8 @@ func TestFilesystem(t *testing.T) {
filePatterns []string
helmSet []string
helmValuesFile []string
skipFiles []string
skipDirs []string
}
tests := []struct {
name string
@@ -40,6 +42,24 @@ func TestFilesystem(t *testing.T) {
},
golden: "testdata/gomod.json.golden",
},
{
name: "gomod with skip files",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gomod",
skipFiles: []string{"/testdata/fixtures/fs/gomod/submod2/go.mod"},
},
golden: "testdata/gomod-skip.json.golden",
},
{
name: "gomod with skip dirs",
args: args{
securityChecks: "vuln",
input: "testdata/fixtures/fs/gomod",
skipDirs: []string{"/testdata/fixtures/fs/gomod/submod2"},
},
golden: "testdata/gomod-skip.json.golden",
},
{
name: "nodejs",
args: args{
@@ -244,6 +264,18 @@ func TestFilesystem(t *testing.T) {
}
}
if len(tt.args.skipFiles) != 0 {
for _, skipFile := range tt.args.skipFiles {
osArgs = append(osArgs, "--skip-files", skipFile)
}
}
if len(tt.args.skipDirs) != 0 {
for _, skipDir := range tt.args.skipDirs {
osArgs = append(osArgs, "--skip-dirs", skipDir)
}
}
// Setup the output file
outputFile := filepath.Join(t.TempDir(), "output.json")
if *update {