@@ -281,3 +281,57 @@ func TestListUncoveredPaths_UnreadableDirectory(t *testing.T) {
281281 assert .Equal (t , []string {"/data" }, result )
282282 assert .Contains (t , logBuf .String (), "ADD: Path '/data' is uncovered" )
283283}
284+
285+ // Test that a child path matching a job exclusion is marked as excluded
286+ // (covers isExcluded true + isCoveredByJob excluded log).
287+ func TestListUncoveredPaths_ChildPathExcludedByJob (t * testing.T ) {
288+ fs := afero .NewMemMapFs ()
289+ _ = fs .MkdirAll ("/data/stuff/docs" , 0755 )
290+ _ = fs .MkdirAll ("/data/stuff/cache" , 0755 )
291+
292+ var logBuf bytes.Buffer
293+
294+ checker := newTestChecker (fs , & logBuf )
295+
296+ cfg := Config {
297+ Sources : []Path {
298+ {Path : "/data/stuff" },
299+ },
300+ Jobs : []Job {
301+ // Source "/data" with exclusion "stuff/cache" so exclusionPath = "/data/stuff/cache"
302+ {Name : "data-backup" , Source : "/data" , Exclusions : []string {"stuff/cache" }},
303+ // Covers the /data/stuff/docs child directly
304+ {Name : "docs" , Source : "/data/stuff/docs" },
305+ },
306+ }
307+
308+ result := checker .ListUncoveredPaths (cfg )
309+
310+ assert .Empty (t , result )
311+ assert .Contains (t , logBuf .String (), "EXCLUDED: Path '/data/stuff/cache' is excluded by job 'data-backup'" )
312+ }
313+
314+ // Test that a source path that is globally excluded is skipped in checkPath.
315+ func TestListUncoveredPaths_GloballyExcludedSourceSkipped (t * testing.T ) {
316+ fs := afero .NewMemMapFs ()
317+ _ = fs .MkdirAll ("/data/cache" , 0755 )
318+
319+ var logBuf bytes.Buffer
320+
321+ checker := newTestChecker (fs , & logBuf )
322+
323+ cfg := Config {
324+ Sources : []Path {
325+ {Path : "/data" , Exclusions : []string {"cache" }},
326+ {Path : "/data/cache" },
327+ },
328+ Jobs : []Job {
329+ {Name : "backup" , Source : "/data" },
330+ },
331+ }
332+
333+ result := checker .ListUncoveredPaths (cfg )
334+
335+ assert .Empty (t , result )
336+ assert .Contains (t , logBuf .String (), "SKIP: Path '/data/cache' is globally excluded" )
337+ }
0 commit comments