forked from andygrunwald/go-jira
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomer_test.go
56 lines (48 loc) · 1.75 KB
/
customer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package jira
import (
"fmt"
"net/http"
"testing"
)
func TestCustomerService_Create(t *testing.T) {
setup()
defer teardown()
const (
wantDisplayName = "Fred F. User"
wantEmailAddress = "[email protected]"
)
testMux.HandleFunc("/rest/servicedeskapi/customer", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testRequestURL(t, r, "/rest/servicedeskapi/customer")
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, `{
"accountId": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b",
"name": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b",
"key": "qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b",
"emailAddress": "%s",
"displayName": "%s",
"active": true,
"timeZone": "Australia/Sydney",
"_links": {
"jiraRest": "https://your-domain.atlassian.net/rest/api/2/user?username=qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b",
"avatarUrls": {
"48x48": "https://avatar-cdn.atlassian.com/image",
"24x24": "https://avatar-cdn.atlassian.com/image",
"16x16": "https://avatar-cdn.atlassian.com/image",
"32x32": "https://avatar-cdn.atlassian.com/image"
},
"self": "https://your-domain.atlassian.net/rest/api/2/user?username=qm:a713c8ea-1075-4e30-9d96-891a7d181739:5ad6d3581db05e2a66fa80b"
}
}`, wantEmailAddress, wantDisplayName)
})
gotCustomer, _, err := testClient.Customer.Create(wantEmailAddress, wantDisplayName)
if err != nil {
t.Fatal(err)
}
if want, got := wantDisplayName, gotCustomer.DisplayName; want != got {
t.Fatalf("want display name: %q, got %q", want, got)
}
if want, got := wantEmailAddress, gotCustomer.EmailAddress; want != got {
t.Fatalf("want email address: %q, got %q", want, got)
}
}