Skip to content

Instantly share code, notes, and snippets.

@flimzy
Last active January 30, 2017 14:31
Show Gist options
  • Save flimzy/b3011e026c1dff179fad70fbc56cfd5c to your computer and use it in GitHub Desktop.
Save flimzy/b3011e026c1dff179fad70fbc56cfd5c to your computer and use it in GitHub Desktop.
1.
Request{
Name: "Tickets for Admin",
Method: "GET",
URL: Server.URL + "/v1/inboxes/9991/tickets/Active.json",
StatusCode: http.StatusOK,
TestContentType: "application/json",
TestCharset: "utf-8",
TestBodyJSON: func(i interface{}) error {
m, ok := i.(map[string]interface{})
if !ok {
return errors.New("JSON response is not a map[string]interface{}")
}
for _, prop := range []string{"count", "maxPages", "page", "ticket"} {
if _, ok := m[prop]; !ok {
return errors.Errorf("JSON response does not contain '%s' property'", prop)
}
}
return nil
},
}.Test(t)
2.
Request(t, "Tickets for Admin").
Method("GET").
URL(Server.URL+"/v1/inboxes/9991/tickets/Active.json").
SetHeader("Accept", "application/json").
Test().
StatusCode(http.StatusOK).
ContentType("application/json").
Charset("utf-8").
TestBodyJSON(func(i interface{}) error {
m, ok := i.(map[string]interface{})
if !ok {
return errors.New("JSON response is not a map[string]interface{}")
}
for _, prop := range []string{"count", "maxPages", "page", "ticket"} {
if _, ok := m[prop]; !ok {
return errors.Errorf("JSON response does not contain '%s' property'", prop)
}
}
return nil
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment