-
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(IssueService.GetWatchers): UserService.GetByAccountID support acc…
…ountId params
- Loading branch information
1 parent
a90dd87
commit 436469b
Showing
4 changed files
with
98 additions
and
3 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 |
---|---|---|
|
@@ -1495,6 +1495,47 @@ func TestIssueService_GetWorklogs(t *testing.T) { | |
} | ||
|
||
func TestIssueService_GetWatchers(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
testMux.HandleFunc("/rest/api/2/issue/10002/watchers", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "GET") | ||
testRequestURL(t, r, "/rest/api/2/issue/10002/watchers") | ||
|
||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/issue/EX-1/watchers","isWatching":false,"watchCount":1,"watchers":[{"self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000","accountId": "000000000000000000000000","displayName":"Fred F. User","active":false}]}`) | ||
}) | ||
|
||
testMux.HandleFunc("/rest/api/2/user", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "GET") | ||
testRequestURL(t, r, "/rest/api/2/user?accountId=000000000000000000000000") | ||
|
||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000","key":"fred","accountId": "000000000000000000000000", | ||
"emailAddress":"[email protected]","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred", | ||
"24x24":"http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","16x16":"http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred", | ||
"32x32":"http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred"},"displayName":"Fred F. User","active":true,"timeZone":"Australia/Sydney","groups":{"size":3,"items":[ | ||
{"name":"jira-user","self":"http://www.example.com/jira/rest/api/2/group?groupname=jira-user"},{"name":"jira-admin", | ||
"self":"http://www.example.com/jira/rest/api/2/group?groupname=jira-admin"},{"name":"important","self":"http://www.example.com/jira/rest/api/2/group?groupname=important" | ||
}]},"applicationRoles":{"size":1,"items":[]},"expand":"groups,applicationRoles"}`) | ||
}) | ||
|
||
watchers, _, err := testClient.Issue.GetWatchers("10002") | ||
if err != nil { | ||
t.Errorf("Error given: %s", err) | ||
return | ||
} | ||
if watchers == nil { | ||
t.Error("Expected watchers. Watchers is nil") | ||
return | ||
} | ||
if len(*watchers) != 1 { | ||
t.Errorf("Expected 1 watcher, got: %d", len(*watchers)) | ||
return | ||
} | ||
if (*watchers)[0].AccountID != "000000000000000000000000" { | ||
t.Error("Expected watcher accountId 000000000000000000000000") | ||
} | ||
} | ||
|
||
func TestIssueService_DeprecatedGetWatchers(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
testMux.HandleFunc("/rest/api/2/issue/10002/watchers", func(w http.ResponseWriter, r *http.Request) { | ||
|
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 |
---|---|---|
|
@@ -29,6 +29,29 @@ func TestUserService_Get_Success(t *testing.T) { | |
} | ||
} | ||
|
||
func TestUserService_GetByAccountID_Success(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
testMux.HandleFunc("/rest/api/2/user", func(w http.ResponseWriter, r *http.Request) { | ||
testMethod(t, r, "GET") | ||
testRequestURL(t, r, "/rest/api/2/user?accountId=000000000000000000000000") | ||
|
||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/user?accountId=000000000000000000000000","accountId": "000000000000000000000000", | ||
"name":"fred","emailAddress":"[email protected]","avatarUrls":{"48x48":"http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred", | ||
"24x24":"http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred","16x16":"http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred", | ||
"32x32":"http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred"},"displayName":"Fred F. User","active":true,"timeZone":"Australia/Sydney","groups":{"size":3,"items":[ | ||
{"name":"jira-user","self":"http://www.example.com/jira/rest/api/2/group?groupname=jira-user"},{"name":"jira-admin", | ||
"self":"http://www.example.com/jira/rest/api/2/group?groupname=jira-admin"},{"name":"important","self":"http://www.example.com/jira/rest/api/2/group?groupname=important" | ||
}]},"applicationRoles":{"size":1,"items":[]},"expand":"groups,applicationRoles"}`) | ||
}) | ||
|
||
if user, _, err := testClient.User.GetByAccountID("000000000000000000000000"); err != nil { | ||
t.Errorf("Error given: %s", err) | ||
} else if user == nil { | ||
t.Error("Expected user. User is nil") | ||
} | ||
} | ||
|
||
func TestUserService_Create(t *testing.T) { | ||
setup() | ||
defer teardown() | ||
|