-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add datatypes module and fix some naming
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package datatypes | ||
|
||
// HeartbeatType are Moira's special internal types of problems. | ||
type HeartbeatType string | ||
|
||
const ( | ||
HearbeatTypeNotSet HeartbeatType = "type_not_set" | ||
HeartbeatNotifierOff HeartbeatType = "notifier_off" | ||
) | ||
|
||
// IsValid checks if such an heartbeat type exists. | ||
func (heartbeatType HeartbeatType) IsValid() bool { | ||
switch heartbeatType { | ||
case HeartbeatNotifierOff: | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
// EmergencyContact is the structure for contacts to which notifications will go in the event of special internal Moira problems. | ||
type EmergencyContact struct { | ||
ContactID string | ||
HeartbeatTypes []HeartbeatType | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package datatypes | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/smartystreets/goconvey/convey" | ||
) | ||
|
||
func TestIsValidHeartbeatType(t *testing.T) { | ||
Convey("Test IsValid heartbeat type", t, func() { | ||
Convey("Test valid cases", func() { | ||
testcases := []HeartbeatType{ | ||
HeartbeatNotifierOff, | ||
} | ||
|
||
for _, testcase := range testcases { | ||
So(testcase.IsValid(), ShouldBeTrue) | ||
} | ||
}) | ||
|
||
Convey("Test invalid cases", func() { | ||
testcases := []HeartbeatType{ | ||
"notifier_on", | ||
"checker_off", | ||
} | ||
|
||
for _, testcase := range testcases { | ||
So(testcase.IsValid(), ShouldBeFalse) | ||
} | ||
}) | ||
}) | ||
} |