2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-24 11:55:28 +00:00

Add TestIndexSave

This commit is contained in:
Alexander Neumann 2017-01-20 14:46:14 +01:00
parent dac18e3bf8
commit 8dd7fe82ff

View File

@ -3,6 +3,7 @@ package index
import (
"math/rand"
"restic"
"restic/checker"
"restic/repository"
"restic/test"
"testing"
@ -204,7 +205,7 @@ func loadIndex(t testing.TB, repo restic.Repository) *Index {
return idx
}
func TestIndexSave(t *testing.T) {
func TestSave(t *testing.T) {
repo, cleanup := createFilledRepo(t, 3, 0)
defer cleanup()
@ -254,6 +255,41 @@ func TestIndexSave(t *testing.T) {
}
}
func TestIndexSave(t *testing.T) {
repo, cleanup := createFilledRepo(t, 3, 0)
defer cleanup()
idx := loadIndex(t, repo)
id, err := idx.Save(repo, idx.IndexIDs.List())
if err != nil {
t.Fatalf("unable to save new index: %v", err)
}
t.Logf("new index saved as %v", id.Str())
for id := range idx.IndexIDs {
t.Logf("remove index %v", id.Str())
err = repo.Backend().Remove(restic.IndexFile, id.String())
if err != nil {
t.Errorf("error removing index %v: %v", id, err)
}
}
idx2 := loadIndex(t, repo)
t.Logf("load new index with %d packs", len(idx2.Packs))
checker := checker.New(repo)
hints, errs := checker.LoadIndex()
for _, h := range hints {
t.Logf("hint: %v\n", h)
}
for _, err := range errs {
t.Errorf("checker found error: %v", err)
}
}
func TestIndexAddRemovePack(t *testing.T) {
repo, cleanup := createFilledRepo(t, 3, 0)
defer cleanup()