Skip to content

Commit

Permalink
Merge pull request #151 from mackerelio/add_suspended_at_to_channels_api
Browse files Browse the repository at this point in the history
Add suspendedAt to Channels API
  • Loading branch information
yohfee authored Dec 20, 2023
2 parents 54fde30 + 7d5fb77 commit 52a7105
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type Channel struct {
Name string `json:"name"`
Type string `json:"type"`

SuspendedAt *int64 `json:"suspendedAt,omitempty"`

// Exists when the type is "email"
Emails *[]string `json:"emails,omitempty"`
UserIDs *[]string `json:"userIds,omitempty"`
Expand Down
19 changes: 16 additions & 3 deletions channels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ func TestFindChannels(t *testing.T) {
"events": []string{"alertGroup"},
},
{
"id": "defabcdef",
"name": "line channel",
"type": "line",
"id": "defabcdef",
"name": "line channel",
"type": "line",
"suspendedAt": 12345678,
},
},
})
Expand Down Expand Up @@ -112,6 +113,18 @@ func TestFindChannels(t *testing.T) {
if channels[3].Type != "line" {
t.Error("request has Type but: ", channels[3].Type)
}
if channels[0].SuspendedAt != nil {
t.Error("request has SuspendedAt but: ", channels[0].SuspendedAt)
}
if channels[1].SuspendedAt != nil {
t.Error("request has SuspendedAt but: ", channels[1].SuspendedAt)
}
if channels[2].SuspendedAt != nil {
t.Error("request has SuspendedAt but: ", channels[2].SuspendedAt)
}
if *channels[3].SuspendedAt != 12345678 {
t.Error("request has SuspendedAt but: ", *channels[3].SuspendedAt)
}
if reflect.DeepEqual(*(channels[0].Emails), []string{"[email protected]", "[email protected]"}) != true {
t.Errorf("Wrong data for emails: %v", *(channels[0].Emails))
}
Expand Down

0 comments on commit 52a7105

Please sign in to comment.