forked from TrueCloudLab/restic
Use CreateIndexFromPacks() in test
This commit is contained in:
parent
43732bb885
commit
5898cb341f
1 changed files with 18 additions and 3 deletions
|
@ -6,7 +6,6 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/restic/restic/internal/index"
|
|
||||||
"github.com/restic/restic/internal/repository"
|
"github.com/restic/restic/internal/repository"
|
||||||
"github.com/restic/restic/internal/restic"
|
"github.com/restic/restic/internal/restic"
|
||||||
)
|
)
|
||||||
|
@ -163,7 +162,21 @@ func saveIndex(t *testing.T, repo restic.Repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func rebuildIndex(t *testing.T, repo restic.Repository) {
|
func rebuildIndex(t *testing.T, repo restic.Repository) {
|
||||||
idx, _, err := index.New(context.TODO(), repo, restic.NewIDSet(), nil)
|
err := repo.SetIndex(repository.NewMasterIndex())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
packs := make(map[restic.ID]int64)
|
||||||
|
err = repo.List(context.TODO(), restic.PackFile, func(id restic.ID, size int64) error {
|
||||||
|
packs[id] = size
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = repo.(*repository.Repository).CreateIndexFromPacks(context.TODO(), packs, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +192,9 @@ func rebuildIndex(t *testing.T, repo restic.Repository) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = idx.Save(context.TODO(), repo, nil)
|
_, err = (repo.Index()).(*repository.MasterIndex).
|
||||||
|
Save(context.TODO(), repo, restic.NewIDSet(), nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue