Skip to content

Commit 20c4bb0

Browse files
add test to check name of the tool
1 parent a073ccc commit 20c4bb0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

cmd/analyze_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,39 @@ func TestGetFileExtension(t *testing.T) {
5656
}
5757
}
5858

59+
func TestGetToolName(t *testing.T) {
60+
tests := []struct {
61+
name string
62+
tool string
63+
version string
64+
expected string
65+
}{
66+
// ESLint cases
67+
{"eslint v7", "eslint", "7.32.0", "eslint"},
68+
{"eslint v8", "eslint", "8.15.0", "eslint-8"},
69+
{"eslint v9", "eslint", "9.1.0", "eslint-9"},
70+
{"eslint unknown version", "eslint", "10.0.0", "eslint"},
71+
72+
// PMD cases
73+
{"pmd v6", "pmd", "6.55.0", "pmd"},
74+
{"pmd v7", "pmd", "7.0.0", "pmd-7"},
75+
{"pmd unknown version", "pmd", "8.0.0", "pmd"},
76+
77+
// Other tools should remain unchanged
78+
{"unknown tool", "bandit", "1.7.4", "bandit"},
79+
}
80+
81+
for _, tt := range tests {
82+
t.Run(tt.name, func(t *testing.T) {
83+
got := getToolName(tt.tool, tt.version)
84+
if got != tt.expected {
85+
t.Errorf("getToolName(%q, %q) = %q; want %q",
86+
tt.tool, tt.version, got, tt.expected)
87+
}
88+
})
89+
}
90+
}
91+
5992
func TestIsToolSupportedForFile(t *testing.T) {
6093
langConfig := &LanguagesConfig{
6194
Tools: []struct {

0 commit comments

Comments
 (0)