1
0
mirror of https://github.com/restic/restic.git synced 2024-06-25 07:47:44 +02:00
restic/internal/checker/testing.go

53 lines
942 B
Go
Raw Normal View History

package checker
import (
2017-06-04 11:16:55 +02:00
"context"
"testing"
2017-07-23 14:21:03 +02:00
2017-07-24 17:42:25 +02:00
"github.com/restic/restic/internal/restic"
)
// TestCheckRepo runs the checker on repo.
func TestCheckRepo(t testing.TB, repo restic.Repository) {
chkr := New(repo, true)
2017-06-04 11:16:55 +02:00
hints, errs := chkr.LoadIndex(context.TODO())
if len(errs) != 0 {
t.Fatalf("errors loading index: %v", errs)
}
if len(hints) != 0 {
t.Fatalf("errors loading index: %v", hints)
}
2016-08-01 21:12:23 +02:00
// packs
errChan := make(chan error)
2017-06-04 11:16:55 +02:00
go chkr.Packs(context.TODO(), errChan)
2016-08-01 21:12:23 +02:00
for err := range errChan {
t.Error(err)
}
// structure
errChan = make(chan error)
go chkr.Structure(context.TODO(), nil, errChan)
for err := range errChan {
t.Error(err)
}
2016-08-01 21:12:23 +02:00
// unused blobs
blobs := chkr.UnusedBlobs(context.TODO())
2016-08-01 21:12:23 +02:00
if len(blobs) > 0 {
t.Errorf("unused blobs found: %v", blobs)
}
// read data
errChan = make(chan error)
go chkr.ReadData(context.TODO(), errChan)
for err := range errChan {
t.Error(err)
}
}