-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprocess_bench.go
64 lines (59 loc) · 2.19 KB
/
process_bench.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package filedriller
import (
"github.com/gomodule/redigo/redis"
"reflect"
"testing"
)
// BenchmarkCreateFileList benchmarks the creation of the file list that woll be processed
func BenchmarkCreateFileList(b *testing.B) {
type args struct {
rootDir string
}
tests := []struct {
name string
args args
want []string
}{
{"File Input List", args{rootDir: "testdata"}, []string{"testdata/1200px-GPLv3_Logo.svg.png", "testdata/emptyfile", "testdata/everywhere.txt", "testdata/test dir/everywhere.txt", "testdata/testDir/everywhere.txt", "testdata/test_dir/everywhere.txt", "testdata/testdir/everywhere.txt", "testdata/testdir/inNSRL/build-classpath", "testdata/textfile.asc", "testdata/töstdir/everywhere.txt"}},
}
for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
if got, _ := CreateFileList(tt.args.rootDir); !reflect.DeepEqual(got, tt.want) {
b.Errorf("CreateFileList() = %v, want %v", got, tt.want)
}
})
}
}
// BenchmarkIdentifyFiles benchmarks the process of identifying one file
func BenchmarkIdentifyFiles(b *testing.B) {
type args struct {
fileList []string
hashDigest string
nsrlEnabled bool
conn redis.Conn
entroEnabled bool
}
conn, _ := redis.Dial("tcp", "127.0.0.1")
wantString := `"testdata/töstdir/everywhere.txt","2","pronom","x-fmt/111","Plain Text File","","text/plain","text match ASCII","match on text only","3abb6677af34ac57c0ca5828fd94f9d886c26ce59a8ce60ecf6778079423dccff1d6f19cb655805d56098e6d38a1a710dee59523eed7511e5a9e4b8ccb3a4686","0000-0000-0000-0000",,"3.5"`
tests := []struct {
name string
args args
want []string
}{
{"Identify Files", args{fileList: []string{"testdata/töstdir/everywhere.txt"},
hashDigest: "sha512",
nsrlEnabled: false,
conn: conn,
entroEnabled: true},
[]string{wantString}}}
for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
got := IdentifyFiles(tt.args.fileList, tt.args.hashDigest, tt.args.nsrlEnabled, tt.args.conn, tt.args.entroEnabled)
gotmodified := got[0]
gotmodin := []string{gotmodified[:264] + ",\"0000-0000-0000-0000\","}
if !reflect.DeepEqual(gotmodin, tt.want) {
b.Errorf("IdentifyFiles() = %v, want %v", gotmodin, tt.want)
}
})
}
}