mirror of
https://github.com/octoleo/restic.git
synced 2025-01-05 16:12:29 +00:00
Add test and benchmark for Scanner
This commit is contained in:
parent
a5e13f1280
commit
0a164ad5e0
@ -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) {
|
func BenchmarkArchiveDirectory(b *testing.B) {
|
||||||
if *benchArchiveDirectory == "" {
|
if *benchArchiveDirectory == "" {
|
||||||
b.Skip("benchdir not set, skipping BenchmarkArchiveDirectory")
|
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 New Issue
Block a user