mirror of
https://github.com/octoleo/restic.git
synced 2024-11-27 23:36:40 +00:00
repository: fix repack test
This commit is contained in:
parent
cbf9cd4a7f
commit
bb92b487f7
@ -38,17 +38,17 @@ func TestRepairBrokenPack(t *testing.T) {
|
|||||||
func testRepairBrokenPack(t *testing.T, version uint) {
|
func testRepairBrokenPack(t *testing.T, version uint) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
damage func(repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet)
|
damage func(t *testing.T, repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"valid pack",
|
"valid pack",
|
||||||
func(repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
func(t *testing.T, repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
||||||
return packsBefore, restic.NewBlobSet()
|
return packsBefore, restic.NewBlobSet()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"broken pack",
|
"broken pack",
|
||||||
func(repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
func(t *testing.T, repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
||||||
wrongBlob := createRandomWrongBlob(t, repo)
|
wrongBlob := createRandomWrongBlob(t, repo)
|
||||||
damagedPacks := findPacksForBlobs(t, repo, restic.NewBlobSet(wrongBlob))
|
damagedPacks := findPacksForBlobs(t, repo, restic.NewBlobSet(wrongBlob))
|
||||||
return damagedPacks, restic.NewBlobSet(wrongBlob)
|
return damagedPacks, restic.NewBlobSet(wrongBlob)
|
||||||
@ -56,7 +56,7 @@ func testRepairBrokenPack(t *testing.T, version uint) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"partially broken pack",
|
"partially broken pack",
|
||||||
func(repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
func(t *testing.T, repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
||||||
// damage one of the pack files
|
// damage one of the pack files
|
||||||
damagedID := packsBefore.List()[0]
|
damagedID := packsBefore.List()[0]
|
||||||
replaceFile(t, repo, backend.Handle{Type: backend.PackFile, Name: damagedID.String()},
|
replaceFile(t, repo, backend.Handle{Type: backend.PackFile, Name: damagedID.String()},
|
||||||
@ -79,7 +79,7 @@ func testRepairBrokenPack(t *testing.T, version uint) {
|
|||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
"truncated pack",
|
"truncated pack",
|
||||||
func(repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
func(t *testing.T, repo restic.Repository, packsBefore restic.IDSet) (restic.IDSet, restic.BlobSet) {
|
||||||
// damage one of the pack files
|
// damage one of the pack files
|
||||||
damagedID := packsBefore.List()[0]
|
damagedID := packsBefore.List()[0]
|
||||||
replaceFile(t, repo, backend.Handle{Type: backend.PackFile, Name: damagedID.String()},
|
replaceFile(t, repo, backend.Handle{Type: backend.PackFile, Name: damagedID.String()},
|
||||||
@ -112,7 +112,7 @@ func testRepairBrokenPack(t *testing.T, version uint) {
|
|||||||
packsBefore := listPacks(t, repo)
|
packsBefore := listPacks(t, repo)
|
||||||
blobsBefore := listBlobs(repo)
|
blobsBefore := listBlobs(repo)
|
||||||
|
|
||||||
toRepair, damagedBlobs := test.damage(repo, packsBefore)
|
toRepair, damagedBlobs := test.damage(t, repo, packsBefore)
|
||||||
|
|
||||||
rtest.OK(t, repository.RepairPacks(context.TODO(), repo, toRepair, &progress.NoopPrinter{}))
|
rtest.OK(t, repository.RepairPacks(context.TODO(), repo, toRepair, &progress.NoopPrinter{}))
|
||||||
// reload index
|
// reload index
|
||||||
|
Loading…
Reference in New Issue
Block a user