github.com/advanderveer/restic@v0.8.1-0.20171209104529-42a8c19aaea6/internal/checker/testing.go (about) 1 package checker 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/restic/restic/internal/restic" 8 ) 9 10 // TestCheckRepo runs the checker on repo. 11 func TestCheckRepo(t testing.TB, repo restic.Repository) { 12 chkr := New(repo) 13 14 hints, errs := chkr.LoadIndex(context.TODO()) 15 if len(errs) != 0 { 16 t.Fatalf("errors loading index: %v", errs) 17 } 18 19 if len(hints) != 0 { 20 t.Fatalf("errors loading index: %v", hints) 21 } 22 23 // packs 24 errChan := make(chan error) 25 go chkr.Packs(context.TODO(), errChan) 26 27 for err := range errChan { 28 t.Error(err) 29 } 30 31 // structure 32 errChan = make(chan error) 33 go chkr.Structure(context.TODO(), errChan) 34 35 for err := range errChan { 36 t.Error(err) 37 } 38 39 // unused blobs 40 blobs := chkr.UnusedBlobs() 41 if len(blobs) > 0 { 42 t.Errorf("unused blobs found: %v", blobs) 43 } 44 45 // read data 46 errChan = make(chan error) 47 go chkr.ReadData(context.TODO(), nil, errChan) 48 49 for err := range errChan { 50 t.Error(err) 51 } 52 }