7
. "github.com/smartystreets/goconvey/convey"
10
func TestConfigCheck(testing *testing.T) {
11
contactTypes := map[string]bool{
15
Convey("SelfCheck disabled", testing, func() {
18
Contacts: []map[string]string{
21
"value": "admin@company.com",
26
Convey("all data valid, should return nil error", func() {
27
actual := config.checkConfig(contactTypes)
28
So(actual, ShouldBeNil)
31
Convey("contacts empty, should return nil error", func() {
32
config.Contacts = []map[string]string{}
33
actual := config.checkConfig(contactTypes)
34
So(actual, ShouldBeNil)
37
Convey("admin sending type not registered, should return nil error", func() {
38
actual := config.checkConfig(make(map[string]bool))
39
So(actual, ShouldBeNil)
42
Convey("admin sending contact empty, should return nil error", func() {
43
config.Contacts = []map[string]string{
48
actual := config.checkConfig(make(map[string]bool))
49
So(actual, ShouldBeNil)
53
Convey("SelfCheck contacts empty, should return contacts must be specified error", testing, func() {
57
actual := config.checkConfig(make(map[string]bool))
58
So(actual, ShouldResemble, fmt.Errorf("contacts must be specified"))
61
Convey("Admin sending type not registered, should not pass check without admin contact type", testing, func() {
64
Contacts: []map[string]string{
67
"value": "admin@company.com",
72
actual := config.checkConfig(make(map[string]bool))
73
So(actual, ShouldResemble, fmt.Errorf("Unknown contact type [admin-mail]"))
76
Convey("Admin sending contact empty, should not pass check without admin contact", testing, func() {
79
Contacts: []map[string]string{
87
contactTypes := map[string]bool{
91
actual := config.checkConfig(contactTypes)
92
So(actual, ShouldResemble, fmt.Errorf("Value for [admin-mail] must be present"))
95
Convey("Has registered valid admin contact, should pass check", testing, func() {
98
Contacts: []map[string]string{
100
"type": "admin-mail",
101
"value": "admin@company.com",
106
contactTypes := map[string]bool{
110
actual := config.checkConfig(contactTypes)
111
So(actual, ShouldBeNil)