From a2b21195899e8626aad1753fa518e5a3a8016e5b Mon Sep 17 00:00:00 2001 From: Artem Yarmoluk Date: Thu, 18 Apr 2019 21:46:52 +0300 Subject: [PATCH] Fix removing teams from escalation policy --- pagerduty/escalation_policy.go | 2 +- pagerduty/escalation_policy_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pagerduty/escalation_policy.go b/pagerduty/escalation_policy.go index 0fe72e2..416705c 100644 --- a/pagerduty/escalation_policy.go +++ b/pagerduty/escalation_policy.go @@ -26,7 +26,7 @@ type EscalationPolicy struct { Self string `json:"self,omitempty"` Services []*ServiceReference `json:"services,omitempty"` Summary string `json:"summary,omitempty"` - Teams []*TeamReference `json:"teams,omitempty"` + Teams []*TeamReference `json:"teams"` Type string `json:"type,omitempty"` } diff --git a/pagerduty/escalation_policy_test.go b/pagerduty/escalation_policy_test.go index b94e655..8bfd66e 100644 --- a/pagerduty/escalation_policy_test.go +++ b/pagerduty/escalation_policy_test.go @@ -129,3 +129,29 @@ func TestEscalationPoliciesUpdate(t *testing.T) { t.Errorf("returned \n\n%#v want \n\n%#v", resp, want) } } + +func TestEscalationPoliciesUpdateTeams(t *testing.T) { + setup() + defer teardown() + + input := &EscalationPolicy{ + Name: "foo", + ID: "1", + Teams: []*TeamReference{}, + } + + mux.HandleFunc("/escalation_policies/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "PUT") + v := new(EscalationPolicy) + json.NewDecoder(r.Body).Decode(v) + if !reflect.DeepEqual(v.EscalationPolicy, input) { + t.Errorf("Request body = %+v, want %+v", v, input) + } + w.Write([]byte(`{"escalation_policy": {"name": "foo", "id": "1", "teams": []}}`)) + }) + + _, _, err := client.EscalationPolicies.Update("1", input) + if err != nil { + t.Fatal(err) + } +}