-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings_test.go
54 lines (44 loc) · 1.02 KB
/
settings_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
package main
import (
"testing"
mapset "github.com/deckarep/golang-set/v2"
)
func TestValidateSettingsAccept(t *testing.T) {
settings := &Settings{
ForbiddenResources: mapset.NewSet("banana"),
DefaultResource: "hay",
}
valid, err := settings.Valid()
if !valid {
t.Errorf("Settings are reported as not valid")
}
if err != nil {
t.Errorf("Unexpected error %+v", err)
}
}
func TestValidateSettingsRejectDefaultResourceEmpty(t *testing.T) {
settings := &Settings{
ForbiddenResources: mapset.NewSet("banana"),
DefaultResource: "",
}
valid, err := settings.Valid()
if valid {
t.Errorf("Settings are reported as valid")
}
if err == nil {
t.Errorf("Unexpected nil error")
}
}
func TestValidateSettingsRejectDefaultResourceForbidden(t *testing.T) {
settings := &Settings{
ForbiddenResources: mapset.NewSet("banana"),
DefaultResource: "banana",
}
valid, err := settings.Valid()
if valid {
t.Errorf("Settings are reported as valid")
}
if err == nil {
t.Errorf("Unexpected nil error")
}
}