Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pagerduty/webhook_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type WebhookSubscriptionService service
type WebhookSubscription struct {
ID string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
Active bool `json:"active,omitempty"`
Active bool `json:"active"`
Description string `json:"description,omitempty"`
DeliveryMethod DeliveryMethod `json:"delivery_method,omitempty"`
Events []string `json:"events,omitempty"`
Expand Down
35 changes: 35 additions & 0 deletions pagerduty/webhook_subscription_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,41 @@ func TestWebhookSubscriptionCreate(t *testing.T) {
}
}

func TestWebhookSubscriptionCreateNonActive(t *testing.T) {
setup()
defer teardown()

input := &WebhookSubscription{Active: false}

mux.HandleFunc("/webhook_subscriptions", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
v := new(WebhookSubscriptionPayload)
json.NewDecoder(r.Body).Decode(v)
encoded, _ := json.Marshal(v)
expectedMarshalValue := `{"webhook_subscription":{"active":false,"delivery_method":{"custom_headers":null},"filter":{}}}`
if string(encoded) != expectedMarshalValue {
t.Errorf("Marshalled body = %s, want %s", string(encoded), expectedMarshalValue)
}
if !reflect.DeepEqual(v.WebhookSubscription, input) {
t.Errorf("Request body = %+v, want %+v", v, input)
}
w.Write([]byte(`{"webhook_subscription":{"id": "1"}}`))
})

resp, _, err := client.WebhookSubscriptions.Create(input)
if err != nil {
t.Fatal(err)
}

want := &WebhookSubscription{
ID: "1",
}

if !reflect.DeepEqual(resp, want) {
t.Errorf("returned \n\n%#v want \n\n%#v", resp, want)
}
}

func TestWebhookSubscriptionGet(t *testing.T) {
setup()
defer teardown()
Expand Down