Skip to content

Commit 1eb3c6e

Browse files
test: Add path validation tests
1 parent c25c315 commit 1eb3c6e

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

cmd/analyze_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,44 @@ func TestEslintInstallationValidationLogic(t *testing.T) {
221221
})
222222
}
223223
}
224+
225+
func TestValidatePaths(t *testing.T) {
226+
tests := []struct {
227+
name string
228+
paths []string
229+
expectError bool
230+
}{
231+
{
232+
name: "valid path",
233+
paths: []string{"."},
234+
expectError: false,
235+
},
236+
{
237+
name: "non-existent file",
238+
paths: []string{"non-existent-file.txt"},
239+
expectError: true,
240+
},
241+
{
242+
name: "multiple paths with one invalid",
243+
paths: []string{".", "non-existent-file.txt"},
244+
expectError: true,
245+
},
246+
{
247+
name: "empty paths",
248+
paths: []string{},
249+
expectError: false,
250+
},
251+
}
252+
253+
for _, tt := range tests {
254+
t.Run(tt.name, func(t *testing.T) {
255+
err := validatePaths(tt.paths)
256+
if tt.expectError {
257+
assert.Error(t, err)
258+
assert.Contains(t, err.Error(), "❌ Error: cannot find file or directory")
259+
} else {
260+
assert.NoError(t, err)
261+
}
262+
})
263+
}
264+
}

0 commit comments

Comments
 (0)