repository: add dedicated test helper

This commit is contained in:
Michael Eischer
2025-09-28 14:25:49 +02:00
parent 82971ad7f0
commit 189b295c30
8 changed files with 56 additions and 31 deletions

View File

@@ -8,7 +8,7 @@ import (
)
// TestCheckRepo runs the checker on repo.
func TestCheckRepo(t testing.TB, repo restic.Repository, skipStructure bool) {
func TestCheckRepo(t testing.TB, repo restic.Repository) {
chkr := New(repo, true)
hints, errs := chkr.LoadIndex(context.TODO(), nil)
@@ -33,23 +33,21 @@ func TestCheckRepo(t testing.TB, repo restic.Repository, skipStructure bool) {
t.Error(err)
}
if !skipStructure {
// structure
errChan = make(chan error)
go chkr.Structure(context.TODO(), nil, errChan)
// structure
errChan = make(chan error)
go chkr.Structure(context.TODO(), nil, errChan)
for err := range errChan {
t.Error(err)
}
for err := range errChan {
t.Error(err)
}
// unused blobs
blobs, err := chkr.UnusedBlobs(context.TODO())
if err != nil {
t.Error(err)
}
if len(blobs) > 0 {
t.Errorf("unused blobs found: %v", blobs)
}
// unused blobs
blobs, err := chkr.UnusedBlobs(context.TODO())
if err != nil {
t.Error(err)
}
if len(blobs) > 0 {
t.Errorf("unused blobs found: %v", blobs)
}
// read data