Add test and benchmark for Scanner

This commit is contained in:
Alexander Neumann
2015-02-16 23:13:23 +01:00
parent a5e13f1280
commit 0a164ad5e0
2 changed files with 29 additions and 9 deletions
+29
View 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)
}
}