mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
Add test and benchmark for LoadIndex
This commit is contained in:
parent
0ad6bdbc09
commit
885b27fdbb
@ -6,11 +6,13 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/restic/restic"
|
"github.com/restic/restic"
|
||||||
"github.com/restic/restic/backend"
|
"github.com/restic/restic/backend"
|
||||||
"github.com/restic/restic/pack"
|
"github.com/restic/restic/pack"
|
||||||
|
"github.com/restic/restic/repository"
|
||||||
. "github.com/restic/restic/test"
|
. "github.com/restic/restic/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -194,3 +196,24 @@ func TestLoadJSONUnpacked(t *testing.T) {
|
|||||||
Equals(t, sn.Hostname, sn2.Hostname)
|
Equals(t, sn.Hostname, sn2.Hostname)
|
||||||
Equals(t, sn.Username, sn2.Username)
|
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 New Issue
Block a user