-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for modifying an incident status and assignees, as per ht…
…tps://developer.pagerduty.com/api-reference/reference/REST/openapiv3.json/paths/~1incidents/put. This resolves a regression from #190
- Loading branch information
1 parent
bafde24
commit 8d5be34
Showing
2 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ func TestIncident_Create(t *testing.T) { | |
testEqual(t, want, res) | ||
} | ||
|
||
func TestIncident_Manage(t *testing.T) { | ||
func TestIncident_Manage_status(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
|
@@ -102,6 +102,116 @@ func TestIncident_Manage(t *testing.T) { | |
testEqual(t, want, res) | ||
} | ||
|
||
func TestIncident_Manage_priority(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
mux.HandleFunc("/incidents", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "PUT") | ||
w.Write([]byte(`{"incidents": [{"title": "foo", "id": "1", "priority": {"id": "PRIORITY_ID_HERE", "type": "priority_reference"}}]}`)) | ||
}) | ||
var listObj = APIListObject{Limit: 0, Offset: 0, More: false, Total: 0} | ||
var client = &Client{apiEndpoint: server.URL, authToken: "foo", HTTPClient: defaultHTTPClient} | ||
from := "[email protected]" | ||
|
||
input := []ManageIncidentsOptions{ | ||
{ | ||
ID: "1", | ||
Type: "incident", | ||
Priority: &APIReference{ | ||
ID: "PRIORITY_ID_HERE", | ||
Type: "priority_reference", | ||
}, | ||
}, | ||
} | ||
|
||
want := &ListIncidentsResponse{ | ||
APIListObject: listObj, | ||
Incidents: []Incident{ | ||
{ | ||
Id: "1", | ||
Title: "foo", | ||
Priority: &Priority{ | ||
APIObject: APIObject{ | ||
ID: "PRIORITY_ID_HERE", | ||
Type: "priority_reference", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
res, err := client.ManageIncidents(from, input) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
testEqual(t, want, res) | ||
} | ||
|
||
func TestIncident_Manage_assignments(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|
||
mux.HandleFunc("/incidents", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "PUT") | ||
w.Write([]byte(`{"incidents": [{"title": "foo", "id": "1", "assignments": [{"assignee":{"id": "ASSIGNEE_ONE", "type": "user_reference"}},{"assignee":{"id": "ASSIGNEE_TWO", "type": "user_reference"}}]}]}`)) | ||
}) | ||
var listObj = APIListObject{Limit: 0, Offset: 0, More: false, Total: 0} | ||
var client = &Client{apiEndpoint: server.URL, authToken: "foo", HTTPClient: defaultHTTPClient} | ||
from := "[email protected]" | ||
|
||
input := []ManageIncidentsOptions{ | ||
{ | ||
ID: "1", | ||
Type: "incident", | ||
Assignments: []Assignee{ | ||
{ | ||
Assignee: APIObject{ | ||
ID: "ASSIGNEE_ONE", | ||
Type: "user_reference", | ||
}, | ||
}, | ||
{ | ||
Assignee: APIObject{ | ||
ID: "ASSIGNEE_TWO", | ||
Type: "user_reference", | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
want := &ListIncidentsResponse{ | ||
APIListObject: listObj, | ||
Incidents: []Incident{ | ||
{ | ||
Id: "1", | ||
Title: "foo", | ||
Assignments: []Assignment{ | ||
{ | ||
Assignee: APIObject{ | ||
ID: "ASSIGNEE_ONE", | ||
Type: "user_reference", | ||
}, | ||
}, | ||
{ | ||
Assignee: APIObject{ | ||
ID: "ASSIGNEE_TWO", | ||
Type: "user_reference", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
res, err := client.ManageIncidents(from, input) | ||
|
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
testEqual(t, want, res) | ||
} | ||
|
||
func TestIncident_Merge(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|