diff --git a/database/redis/emergency_contact_test.go b/database/redis/emergency_contact_test.go index 9da23eb0a..cd5a36993 100644 --- a/database/redis/emergency_contact_test.go +++ b/database/redis/emergency_contact_test.go @@ -18,12 +18,12 @@ var ( testEmergencyContact = datatypes.EmergencyContact{ ContactID: testContactID, - HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifierOff}, + HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifier}, } testEmergencyContact2 = datatypes.EmergencyContact{ ContactID: testContactID2, - HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifierOff}, + HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifier}, } testEmergencyContact3 = datatypes.EmergencyContact{ @@ -147,7 +147,7 @@ func TestGetHeartbeatTypeContactIDs(t *testing.T) { Convey("Test GetHeartbeatTypeContactIDs", t, func() { Convey("Without any emergency contacts by heartbeat type", func() { - emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifierOff) + emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifier) So(err, ShouldBeNil) So(emergencyContactIDs, ShouldBeEmpty) }) @@ -159,7 +159,7 @@ func TestGetHeartbeatTypeContactIDs(t *testing.T) { testEmergencyContact3, }) - emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifierOff) + emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifier) So(err, ShouldBeNil) assert.ElementsMatch(t, emergencyContactIDs, []string{ testContactID, @@ -197,7 +197,7 @@ func TestSaveEmergencyContact(t *testing.T) { So(err, ShouldBeNil) So(emergencyContacts, ShouldResemble, expectedEmergencyContacts) - emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifierOff) + emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifier) So(err, ShouldBeNil) So(emergencyContactIDs, ShouldResemble, expectedEmergencyContactIDs) }) @@ -230,7 +230,7 @@ func TestSaveEmergencyContacts(t *testing.T) { So(err, ShouldBeNil) assert.ElementsMatch(t, emergencyContacts, expectedEmergencyContacts) - emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifierOff) + emergencyContactIDs, err := database.GetHeartbeatTypeContactIDs(datatypes.HeartbeatNotifier) So(err, ShouldBeNil) assert.ElementsMatch(t, emergencyContactIDs, expectedEmergencyContactIDs) }) diff --git a/database/redis/reply/emergency_contacts_test.go b/database/redis/reply/emergency_contacts_test.go index 4916a3c94..15b981d23 100644 --- a/database/redis/reply/emergency_contacts_test.go +++ b/database/redis/reply/emergency_contacts_test.go @@ -10,14 +10,14 @@ import ( ) const ( - testEmergencyContactVal = `{"contact_id":"test-contact-id","heartbeat_types":["notifier_off"]}` + testEmergencyContactVal = `{"contact_id":"test-contact-id","heartbeat_types":["heartbeat_notifier"]}` testEmptyEmergencyContactVal = `{"contact_id":"","heartbeat_types":null}` ) var ( testEmergencyContact = datatypes.EmergencyContact{ ContactID: "test-contact-id", - HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifierOff}, + HeartbeatTypes: []datatypes.HeartbeatType{datatypes.HeartbeatNotifier}, } testEmptyEmergencyContact = datatypes.EmergencyContact{} ) diff --git a/datatypes/emergency_contact.go b/datatypes/emergency_contact.go index deec88061..1a1bb02d1 100644 --- a/datatypes/emergency_contact.go +++ b/datatypes/emergency_contact.go @@ -4,14 +4,18 @@ package datatypes type HeartbeatType string const ( - HeartbeatTypeNotSet HeartbeatType = "type_not_set" - HeartbeatNotifierOff HeartbeatType = "notifier_off" + HeartbeatTypeNotSet HeartbeatType = "heartbeat_type_not_set" + HeartbeatNotifier HeartbeatType = "heartbeat_notifier" + HeartbeatDatabase HeartbeatType = "heartbeat_database" + HeartbeatLocalChecker HeartbeatType = "heartbeat_local_checker" + HeartbeatRemoteChecker HeartbeatType = "heartbeat_remote_checker" + HeartbeatFilter HeartbeatType = "heartbeat_filter" ) // IsValid checks if such an heartbeat type exists. func (heartbeatType HeartbeatType) IsValid() bool { switch heartbeatType { - case HeartbeatNotifierOff: + case HeartbeatNotifier, HeartbeatDatabase, HeartbeatLocalChecker, HeartbeatRemoteChecker, HeartbeatFilter: return true default: return false diff --git a/datatypes/emergency_contact_test.go b/datatypes/emergency_contact_test.go index ec0389b32..4e9b85b43 100644 --- a/datatypes/emergency_contact_test.go +++ b/datatypes/emergency_contact_test.go @@ -10,7 +10,11 @@ func TestIsValidHeartbeatType(t *testing.T) { Convey("Test IsValid heartbeat type", t, func() { Convey("Test valid cases", func() { testcases := []HeartbeatType{ - HeartbeatNotifierOff, + HeartbeatNotifier, + HeartbeatDatabase, + HeartbeatLocalChecker, + HeartbeatRemoteChecker, + HeartbeatFilter, } for _, testcase := range testcases {