backup: test that parent directory errors can be correctly filtered

This commit is contained in:
Michael Eischer 2025-06-12 22:43:45 +02:00
parent d57b01d6eb
commit b67b88a0c0

View file

@ -1846,8 +1846,8 @@ func TestArchiverParent(t *testing.T) {
func TestArchiverErrorReporting(t *testing.T) {
ignoreErrorForBasename := func(basename string) ErrorFunc {
return func(item string, err error) error {
if filepath.Base(item) == "targetfile" {
t.Logf("ignoring error for targetfile: %v", err)
if filepath.Base(item) == basename {
t.Logf("ignoring error for %v: %v", basename, err)
return nil
}
@ -1936,6 +1936,14 @@ func TestArchiverErrorReporting(t *testing.T) {
src: TestDir{},
errStr: "stat subdir: no such file or directory",
},
{
name: "parent-dir-missing-filtered",
targets: []string{"targetfile", "subdir/missing"},
src: TestDir{
"targetfile": TestFile{Content: "foobar"},
},
errFn: ignoreErrorForBasename("subdir"),
},
}
for _, test := range tests {