...
1 package desktop
2
3 import (
4 "fmt"
5 "os"
6 "path"
7 "testing"
8 )
9
10 func TestScan(t *testing.T) {
11 dirs, err := getTestScanDirs()
12 if err != nil {
13 t.Fatalf("failed to get test scan dirs: %s", err)
14 }
15
16 entries, err := Scan(dirs)
17 if err != nil {
18 t.Fatalf("failed to scan %s: %s", dirs[0], err)
19 }
20 _ = entries
21 }
22
23 func BenchmarkScan(b *testing.B) {
24 dirs, err := getTestScanDirs()
25 if err != nil {
26 b.Fatalf("failed to get test scan dirs: %s", err)
27 }
28
29 var entries [][]*Entry
30 b.ResetTimer()
31 for i := 0; i < b.N; i++ {
32 entries, err = Scan(dirs)
33 if err != nil {
34 b.Fatal(err)
35 }
36 }
37 _ = entries
38 }
39
40 func getTestScanDirs() ([]string, error) {
41 wd, err := os.Getwd()
42 if err != nil {
43 return nil, fmt.Errorf("failed to get current working directory: %s", err)
44 }
45
46 return []string{path.Join(wd, "test")}, nil
47 }
48
View as plain text