2016-07-31 10:09:44 +00:00
|
|
|
package checker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"restic/repository"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TestCheckRepo runs the checker on repo.
|
|
|
|
func TestCheckRepo(t testing.TB, repo *repository.Repository) {
|
|
|
|
chkr := New(repo)
|
|
|
|
|
|
|
|
hints, errs := chkr.LoadIndex()
|
|
|
|
if len(errs) != 0 {
|
|
|
|
t.Fatalf("errors loading index: %v", errs)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(hints) != 0 {
|
|
|
|
t.Fatalf("errors loading index: %v", hints)
|
|
|
|
}
|
|
|
|
|
|
|
|
done := make(chan struct{})
|
|
|
|
defer close(done)
|
2016-08-01 19:12:23 +00:00
|
|
|
|
|
|
|
// packs
|
2016-07-31 10:09:44 +00:00
|
|
|
errChan := make(chan error)
|
2016-08-01 19:12:23 +00:00
|
|
|
go chkr.Packs(errChan, done)
|
|
|
|
|
|
|
|
for err := range errChan {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// structure
|
|
|
|
errChan = make(chan error)
|
2016-07-31 10:09:44 +00:00
|
|
|
go chkr.Structure(errChan, done)
|
|
|
|
|
|
|
|
for err := range errChan {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
|
2016-08-01 19:12:23 +00:00
|
|
|
// unused blobs
|
|
|
|
blobs := chkr.UnusedBlobs()
|
|
|
|
if len(blobs) > 0 {
|
|
|
|
t.Errorf("unused blobs found: %v", blobs)
|
|
|
|
}
|
|
|
|
|
|
|
|
// read data
|
2016-07-31 10:09:44 +00:00
|
|
|
errChan = make(chan error)
|
|
|
|
go chkr.ReadData(nil, errChan, done)
|
|
|
|
|
|
|
|
for err := range errChan {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|