Skip to content

Commit 3ca90a4

Browse files
committed
Add positive test for project.GetPermissionScheme
1 parent 4ecfcbf commit 3ca90a4

1 file changed

Lines changed: 34 additions & 5 deletions

File tree

project_test.go

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestProjectService_ListWithOptions(t *testing.T) {
5555
}
5656
}
5757

58-
5958
func TestProjectService_Get(t *testing.T) {
6059
setup()
6160
defer teardown()
@@ -104,7 +103,7 @@ func TestProjectService_Get_NoProject(t *testing.T) {
104103
}
105104
}
106105

107-
func TestProjectService_GetPermissionScheme(t *testing.T) {
106+
func TestProjectService_GetPermissionScheme_Failure(t *testing.T) {
108107
setup()
109108
defer teardown()
110109
testAPIEdpoint := "/rest/api/2/project/99999999/permissionscheme"
@@ -115,9 +114,9 @@ func TestProjectService_GetPermissionScheme(t *testing.T) {
115114
fmt.Fprint(w, nil)
116115
})
117116

118-
projects, resp, err := testClient.Project.GetPermissionScheme("99999999")
119-
if projects != nil {
120-
t.Errorf("Expected nil. Got %+v", projects)
117+
permissionScheme, resp, err := testClient.Project.GetPermissionScheme("99999999")
118+
if permissionScheme != nil {
119+
t.Errorf("Expected nil. Got %+v", permissionScheme)
121120
}
122121

123122
if resp.Status == "404" {
@@ -127,3 +126,33 @@ func TestProjectService_GetPermissionScheme(t *testing.T) {
127126
t.Errorf("Error given: %s", err)
128127
}
129128
}
129+
130+
func TestProjectService_GetPermissionScheme_Success(t *testing.T) {
131+
setup()
132+
defer teardown()
133+
testAPIEdpoint := "/rest/api/2/project/99999999/permissionscheme"
134+
135+
testMux.HandleFunc(testAPIEdpoint, func(w http.ResponseWriter, r *http.Request) {
136+
testMethod(t, r, "GET")
137+
testRequestURL(t, r, testAPIEdpoint)
138+
fmt.Fprint(w, `{
139+
"expand": "permissions,user,group,projectRole,field,all",
140+
"id": 10201,
141+
"self": "https://www.example.com/rest/api/2/permissionscheme/10201",
142+
"name": "Project for specific-users",
143+
"description": "Projects that can only see for people belonging to specific-users group"
144+
}`)
145+
})
146+
147+
permissionScheme, resp, err := testClient.Project.GetPermissionScheme("99999999")
148+
if permissionScheme.ID != 10201 {
149+
t.Errorf("Expected Permission Scheme ID. Got %+v", permissionScheme)
150+
}
151+
152+
if resp.Status == "404" {
153+
t.Errorf("Expected status 404. Got %s", resp.Status)
154+
}
155+
if err != nil {
156+
t.Errorf("Error given: %s", err)
157+
}
158+
}

0 commit comments

Comments
 (0)