-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathload_test.go
More file actions
51 lines (49 loc) · 1 KB
/
load_test.go
File metadata and controls
51 lines (49 loc) · 1 KB
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
package diffence
import (
"reflect"
"testing"
)
func Test_readRules(t *testing.T) {
type args struct {
fPath string
}
tests := []struct {
name string
args args
want *[]Rule
wantErr bool
}{
{
name: "Read rules from file",
args: args{fPath: "test/fixtures/rules/rules.json"},
want: &[]Rule{
{
Caption: "Contains word: password",
Description: nil,
Part: "filename",
Pattern: "password",
Type: "regex",
},
},
wantErr: false,
},
{
name: "Read rules from file",
args: args{fPath: "test/fixtures/does_not_exist.json"},
want: &[]Rule{},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := LoadRulesJSON(tt.args.fPath)
if (err != nil) != tt.wantErr {
t.Errorf("LoadRulesJSON() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("LoadRulesJSON() = %v, want %v", got, tt.want)
}
})
}
}