-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffect_test.go
68 lines (61 loc) · 1.09 KB
/
effect_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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package leanauthz_test
import (
"testing"
authz "github.com/lazharichir/leanauthz"
)
func TestParseEffect(t *testing.T) {
tests := []struct {
name string
str string
want authz.Effect
}{
{
name: "valid allow",
str: "allow",
want: authz.ALLOW,
},
{
name: "valid deny",
str: "deny",
want: authz.DENY,
},
{
name: "valid allow in caps",
str: "ALLOW",
want: authz.ALLOW,
},
{
name: "valid deny in caps",
str: "DENY",
want: authz.DENY,
},
{
name: "invalid effect",
str: "invalid",
want: authz.DENY,
},
{
name: "invalid effect (whitespace)",
str: "allow ",
want: authz.DENY,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := authz.ParseEffect(tt.str)
if got != tt.want {
t.Errorf("ParseEffect() = %v, want %v", got, tt.want)
}
})
}
}
func TestEffect_Allow(t *testing.T) {
if authz.ALLOW != "allow" {
t.Errorf("ALLOW constant is not equal to 'allow'")
}
}
func TestEffect_Deny(t *testing.T) {
if authz.DENY != "deny" {
t.Errorf("DENY constant is not equal to 'deny'")
}
}