(t *testing.T)
| 50 | } |
| 51 | |
| 52 | func TestScanFilesSkipsDirectories(t *testing.T) { |
| 53 | tmpDir := t.TempDir() |
| 54 | |
| 55 | file1 := filepath.Join(tmpDir, "test.go") |
| 56 | subDir := filepath.Join(tmpDir, "subdir") |
| 57 | |
| 58 | require.NoError(t, os.WriteFile(file1, []byte("package main\n"), 0644)) |
| 59 | require.NoError(t, os.MkdirAll(subDir, 0755)) |
| 60 | |
| 61 | // Include a directory in the file list - should be skipped |
| 62 | files := []string{file1, subDir} |
| 63 | |
| 64 | jsonData, err := ScanFiles(files, "test") |
| 65 | require.NoError(t, err) |
| 66 | |
| 67 | var result []any |
| 68 | err = json.Unmarshal(jsonData, &result) |
| 69 | require.NoError(t, err) |
| 70 | |
| 71 | // Check that only 1 file was counted (directory was skipped) |
| 72 | report := result[1].(map[string]any) |
| 73 | assert.Equal(t, float64(1), report["files"]) |
| 74 | } |
| 75 | |
| 76 | func TestScanFilesNonExistentFile(t *testing.T) { |
| 77 | files := []string{"/nonexistent/file.go"} |
nothing calls this directly
no test coverage detected