-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdb_test.go
45 lines (41 loc) · 1022 Bytes
/
db_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
package filetrove
import (
"os"
"testing"
)
func TestCreateFileTroveDB(t *testing.T) {
type args struct {
dbpath string
version string
initdate string
}
tests := []struct {
name string
args args
wantErr bool
}{
{"Create database", args{dbpath: ".", version: "TEST", initdate: "23.05.1949"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := CreateFileTroveDB(tt.args.dbpath, tt.args.version, tt.args.initdate); (err != nil) != tt.wantErr {
t.Errorf("CreateFileTroveDB() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
// Remove file after testing
err := os.Remove("filetrove.db")
if err != nil {
println("Could not remove test file: filetrove.db")
}
}
// FuzzCreateFileTroveDB fuzzes three input string values
func FuzzCreateFileTroveDB(f *testing.F) {
f.Fuzz(func(t *testing.T, a string, b string, c string) {
CreateFileTroveDB(a, b, c)
err := os.Remove(a)
if err != nil {
println("Could not remove test file")
}
})
}