Skip to content

Commit

Permalink
add datatypes module and fix some naming
Browse files Browse the repository at this point in the history
  • Loading branch information
almostinf committed Oct 1, 2024
1 parent b6ca9d2 commit a644573
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
25 changes: 25 additions & 0 deletions datatypes/emergency_contact.go
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
}
32 changes: 32 additions & 0 deletions datatypes/emergency_contact_test.go
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)
}
})
})
}

0 comments on commit a644573

Please sign in to comment.