mirror of
https://github.com/restic/restic.git
synced 2024-12-22 15:57:07 +00:00
Add failing test for fileRestorer
This commit is contained in:
parent
f647614e24
commit
573221aa40
1 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/crypto"
|
"github.com/restic/restic/internal/crypto"
|
||||||
|
"github.com/restic/restic/internal/errors"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
rtest "github.com/restic/restic/internal/test"
|
rtest "github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
@ -237,3 +238,29 @@ func TestFileRestorerPackSkip(t *testing.T) {
|
||||||
},
|
},
|
||||||
}, files)
|
}, files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestErrorRestoreFiles(t *testing.T) {
|
||||||
|
tempdir, cleanup := rtest.TempDir(t)
|
||||||
|
defer cleanup()
|
||||||
|
content := []TestFile{
|
||||||
|
{
|
||||||
|
name: "file1",
|
||||||
|
blobs: []TestBlob{
|
||||||
|
{"data1-1", "pack1-1"},
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
|
||||||
|
repo := newTestRepo(content)
|
||||||
|
|
||||||
|
loadError := errors.New("load error")
|
||||||
|
// loader always returns an error
|
||||||
|
repo.loader = func(ctx context.Context, h restic.Handle, length int, offset int64, fn func(rd io.Reader) error) error {
|
||||||
|
return loadError
|
||||||
|
}
|
||||||
|
|
||||||
|
r := newFileRestorer(tempdir, repo.loader, repo.key, repo.Lookup)
|
||||||
|
r.files = repo.files
|
||||||
|
|
||||||
|
err := r.restoreFiles(context.TODO())
|
||||||
|
rtest.Assert(t, err != nil, "restoreFiles should have reported an error!")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue