forked from TrueCloudLab/restic
Add test and benchmark for Scanner
This commit is contained in:
parent
a5e13f1280
commit
0a164ad5e0
2 changed files with 29 additions and 9 deletions
|
@ -121,15 +121,6 @@ func BenchmarkChunkEncryptParallel(b *testing.B) {
|
|||
})
|
||||
}
|
||||
|
||||
func BenchmarkScanner(b *testing.B) {
|
||||
if *benchArchiveDirectory == "" {
|
||||
b.Skip("benchdir not set, skipping BenchmarkScanner")
|
||||
}
|
||||
|
||||
_, err := restic.NewScanner(nil).Scan(*benchArchiveDirectory)
|
||||
ok(b, err)
|
||||
}
|
||||
|
||||
func BenchmarkArchiveDirectory(b *testing.B) {
|
||||
if *benchArchiveDirectory == "" {
|
||||
b.Skip("benchdir not set, skipping BenchmarkArchiveDirectory")
|
||||
|
|
29
scanner_test.go
Normal file
29
scanner_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package restic_test
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"testing"
|
||||
|
||||
"github.com/restic/restic"
|
||||
)
|
||||
|
||||
var scanDir = flag.String("test.scandir", ".", "test/benchmark scanning a real directory (default: .)")
|
||||
|
||||
func TestScanner(t *testing.T) {
|
||||
sc := restic.NewScanner(nil)
|
||||
|
||||
tree, err := sc.Scan(*scanDir)
|
||||
ok(t, err)
|
||||
|
||||
stats := tree.Stat()
|
||||
|
||||
assert(t, stats.Files > 0,
|
||||
"no files in dir %v", *scanDir)
|
||||
}
|
||||
|
||||
func BenchmarkScanner(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := restic.NewScanner(nil).Scan(*scanDir)
|
||||
ok(b, err)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue