Skip to content

Commit

Permalink
Add missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nukosuke committed Mar 11, 2019
1 parent b77832c commit 0cc327e
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fixture/POST/ticket_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ticket_field": {
"url": "https://example.zendesk.com/api/v2/ticket_fields/360011737434.json",
"id": 360011737434,
"type": "subject",
"title": "Subject",
"raw_title": "Subject",
"description": "",
"raw_description": "",
"position": 0,
"active": true,
"required": false,
"collapsed_for_agents": false,
"regexp_for_validation": null,
"title_in_portal": "Subject",
"raw_title_in_portal": "Subject",
"visible_in_portal": true,
"editable_in_portal": true,
"required_in_portal": true,
"tag": null,
"created_at": "2018-11-23T16:05:12Z",
"updated_at": "2018-11-24T10:54:05Z",
"removable": false,
"agent_description": null
}
}
43 changes: 43 additions & 0 deletions fixture/POST/triggers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"trigger": {
"url": "https://example.zendesk.com/api/v2/triggers/360056295714.json",
"id": 360056295714,
"title": "Notify requester of received request",
"active": true,
"updated_at": "2018-11-23T16:05:14Z",
"created_at": "2018-11-23T16:05:12Z",
"actions": [
{
"field": "notification_user",
"value": [
"requester_id",
"[Request received]",
"Your request ({{ticket.id}}) has been received and is being reviewed by our support staff.\n\nTo add additional comments, reply to this email."
]
}
],
"conditions": {
"all": [
{
"field": "update_type",
"operator": "is",
"value": "Create"
},
{
"field": "status",
"operator": "is_not",
"value": "solved"
},
{
"field": "ticket_is_public",
"operator": "is",
"value": "public"
}
],
"any": []
},
"description": null,
"position": 0,
"raw_title": "Notify requester of received request"
}
}
11 changes: 11 additions & 0 deletions zendesk/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ func TestGetGroups(t *testing.T) {
t.Fatalf("expected length of groups is 1, but got %d", len(groups))
}
}

func TestCreateGroup(t *testing.T) {
mockAPI := newMockAPIWithStatus(http.MethodPost, "groups.json", http.StatusCreated)
client := newTestClient(mockAPI)
defer mockAPI.Close()

_, err := client.CreateGroup(Group{})
if err != nil {
t.Fatalf("Failed to send request to create group: %s", err)
}
}
11 changes: 11 additions & 0 deletions zendesk/ticket_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ func TestGetTicketField(t *testing.T) {
t.Fatalf("Returned ticket field does not have the expected ID %d. Ticket id is %d", expectedID, ticketField.ID)
}
}

func TestCreateTicketField(t *testing.T) {
mockAPI := newMockAPIWithStatus(http.MethodPost, "ticket_fields.json", http.StatusCreated)
client := newTestClient(mockAPI)
defer mockAPI.Close()

_, err := client.CreateTicketField(TicketField{})
if err != nil {
t.Fatalf("Failed to send request to create ticket field: %s", err)
}
}
11 changes: 11 additions & 0 deletions zendesk/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,14 @@ func TestGetTriggers(t *testing.T) {
t.Fatalf("expected length of triggers is , but got %d", len(triggers))
}
}

func TestCreateTrigger(t *testing.T) {
mockAPI := newMockAPIWithStatus(http.MethodPost, "triggers.json", http.StatusCreated)
client := newTestClient(mockAPI)
defer mockAPI.Close()

_, err := client.CreateTrigger(Trigger{})
if err != nil {
t.Fatalf("Failed to send request to create trigger: %s", err)
}
}

0 comments on commit 0cc327e

Please sign in to comment.