forked from TrueCloudLab/restic
check: allow tests to only verify pack&index integrity
This commit is contained in:
parent
4c9a10ca37
commit
7ba5e95a82
3 changed files with 19 additions and 17 deletions
|
@ -1430,7 +1430,7 @@ func TestArchiverSnapshot(t *testing.T) {
|
||||||
}
|
}
|
||||||
TestEnsureSnapshot(t, repo, snapshotID, want)
|
TestEnsureSnapshot(t, repo, snapshotID, want)
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
|
|
||||||
// check that the snapshot contains the targets with absolute paths
|
// check that the snapshot contains the targets with absolute paths
|
||||||
for i, target := range sn.Paths {
|
for i, target := range sn.Paths {
|
||||||
|
@ -1590,7 +1590,7 @@ func TestArchiverSnapshotSelect(t *testing.T) {
|
||||||
}
|
}
|
||||||
TestEnsureSnapshot(t, repo, snapshotID, want)
|
TestEnsureSnapshot(t, repo, snapshotID, want)
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1794,7 +1794,7 @@ func TestArchiverParent(t *testing.T) {
|
||||||
t.Logf("second backup saved as %v", secondSnapshotID.Str())
|
t.Logf("second backup saved as %v", secondSnapshotID.Str())
|
||||||
t.Logf("testfs: %v", testFS)
|
t.Logf("testfs: %v", testFS)
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1927,7 +1927,7 @@ func TestArchiverErrorReporting(t *testing.T) {
|
||||||
}
|
}
|
||||||
TestEnsureSnapshot(t, repo, snapshotID, want)
|
TestEnsureSnapshot(t, repo, snapshotID, want)
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2288,7 +2288,7 @@ func TestMetadataChanged(t *testing.T) {
|
||||||
// make sure the content matches
|
// make sure the content matches
|
||||||
TestEnsureFileContent(context.Background(), t, repo, "testfile", node3, files["testfile"].(TestFile))
|
TestEnsureFileContent(context.Background(), t, repo, "testfile", node3, files["testfile"].(TestFile))
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRacyFileSwap(t *testing.T) {
|
func TestRacyFileSwap(t *testing.T) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestCheckRepo runs the checker on repo.
|
// TestCheckRepo runs the checker on repo.
|
||||||
func TestCheckRepo(t testing.TB, repo restic.Repository) {
|
func TestCheckRepo(t testing.TB, repo restic.Repository, skipStructure bool) {
|
||||||
chkr := New(repo, true)
|
chkr := New(repo, true)
|
||||||
|
|
||||||
hints, errs := chkr.LoadIndex(context.TODO(), nil)
|
hints, errs := chkr.LoadIndex(context.TODO(), nil)
|
||||||
|
@ -33,6 +33,7 @@ func TestCheckRepo(t testing.TB, repo restic.Repository) {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !skipStructure {
|
||||||
// structure
|
// structure
|
||||||
errChan = make(chan error)
|
errChan = make(chan error)
|
||||||
go chkr.Structure(context.TODO(), nil, errChan)
|
go chkr.Structure(context.TODO(), nil, errChan)
|
||||||
|
@ -46,6 +47,7 @@ func TestCheckRepo(t testing.TB, repo restic.Repository) {
|
||||||
if len(blobs) > 0 {
|
if len(blobs) > 0 {
|
||||||
t.Errorf("unused blobs found: %v", blobs)
|
t.Errorf("unused blobs found: %v", blobs)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// read data
|
// read data
|
||||||
errChan = make(chan error)
|
errChan = make(chan error)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func TestCreateSnapshot(t *testing.T) {
|
||||||
t.Fatalf("snapshot has zero tree ID")
|
t.Fatalf("snapshot has zero tree ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
checker.TestCheckRepo(t, repo)
|
checker.TestCheckRepo(t, repo, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkTestCreateSnapshot(t *testing.B) {
|
func BenchmarkTestCreateSnapshot(t *testing.B) {
|
||||||
|
|
Loading…
Reference in a new issue