forked from TrueCloudLab/restic
Move test checking repo code to checker package
This commit is contained in:
parent
6c2334f505
commit
5c32ae15c2
2 changed files with 37 additions and 26 deletions
36
src/restic/checker/testing.go
Normal file
36
src/restic/checker/testing.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
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)
|
||||
errChan := make(chan error)
|
||||
go chkr.Structure(errChan, done)
|
||||
|
||||
for err := range errChan {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
errChan = make(chan error)
|
||||
go chkr.ReadData(nil, errChan, done)
|
||||
|
||||
for err := range errChan {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
|
@ -45,30 +45,5 @@ func TestCreateSnapshot(t *testing.T) {
|
|||
t.Fatalf("snapshot has zero tree ID")
|
||||
}
|
||||
|
||||
chkr := checker.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)
|
||||
errChan := make(chan error)
|
||||
go chkr.Structure(errChan, done)
|
||||
|
||||
for err := range errChan {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
errChan = make(chan error)
|
||||
go chkr.ReadData(nil, errChan, done)
|
||||
|
||||
for err := range errChan {
|
||||
t.Error(err)
|
||||
}
|
||||
checker.TestCheckRepo(t, repo)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue