mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
Add test and benchmark for LoadIndex
This commit is contained in:
parent
0ad6bdbc09
commit
885b27fdbb
2 changed files with 23 additions and 0 deletions
|
@ -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
BIN
repository/testdata/test-repo.tar.gz
vendored
Normal file
Binary file not shown.
Loading…
Reference in a new issue