2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-05 18:40:49 +00:00

Add test and benchmark for LoadIndex

This commit is contained in:
Alexander Neumann 2015-07-04 16:52:17 +02:00
parent 0ad6bdbc09
commit 885b27fdbb
2 changed files with 23 additions and 0 deletions

View File

@ -6,11 +6,13 @@ import (
"crypto/sha256"
"encoding/json"
"io"
"path/filepath"
"testing"
"github.com/restic/restic"
"github.com/restic/restic/backend"
"github.com/restic/restic/pack"
"github.com/restic/restic/repository"
. "github.com/restic/restic/test"
)
@ -194,3 +196,24 @@ func TestLoadJSONUnpacked(t *testing.T) {
Equals(t, sn.Hostname, sn2.Hostname)
Equals(t, sn.Username, sn2.Username)
}
var repoFixture = filepath.Join("testdata", "test-repo.tar.gz")
func TestLoadIndex(t *testing.T) {
WithTestEnvironment(t, repoFixture, func(repodir string) {
repo := OpenLocalRepo(t, repodir)
OK(t, repo.LoadIndex())
})
}
func BenchmarkLoadIndex(b *testing.B) {
WithTestEnvironment(b, repoFixture, func(repodir string) {
repo := OpenLocalRepo(b, repodir)
b.ResetTimer()
for i := 0; i < b.N; i++ {
repo.SetIndex(repository.NewIndex())
OK(b, repo.LoadIndex())
}
})
}

BIN
repository/testdata/test-repo.tar.gz vendored Normal file

Binary file not shown.