-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfileutils_test.go
48 lines (42 loc) · 974 Bytes
/
fileutils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package fileutils
import (
"os"
"path/filepath"
"testing"
)
func FilterMp3(fileInfo os.FileInfo) bool {
if filepath.Ext(fileInfo.Name()) == ".mp3" {
return true
}
return false
}
func TestTraverseDirectoriesWithoutFilter(t *testing.T) {
rootFolder, err := ReadFolderContent("/home/he4d/Musik", nil)
if err != nil {
t.Error(err)
}
rootFolder.WriteStructure(os.Stdout, 0)
}
func TestTraverseDirectoriesWithFilter(t *testing.T) {
rootFolder, err := ReadFolderContent("/home/he4d/Musik", FilterMp3)
if err != nil {
t.Error(err)
}
rootFolder.WriteStructure(os.Stdout, 0)
}
func BenchmarkTraverseDirectoriesWithoutFilter(b *testing.B) {
for n := 0; n < b.N; n++ {
_, err := ReadFolderContent("/home/he4d/Musik", nil)
if err != nil {
b.Error(err)
}
}
}
func BenchmarkTraverseDirectoriesWithFilter(b *testing.B) {
for n := 0; n < b.N; n++ {
_, err := ReadFolderContent("/home/he4d/Musik", FilterMp3)
if err != nil {
b.Error(err)
}
}
}