Skip to content

Commit

Permalink
Merge pull request #1750 from WinXaito/issue_group_milestone
Browse files Browse the repository at this point in the history
Add the field GroupID to the Milestone struct
  • Loading branch information
svanharmelen authored Jul 5, 2023
2 parents 52a9201 + 1ef4e91 commit a843ebc
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
3 changes: 2 additions & 1 deletion group_boards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func TestGroupIssueBoardsService_UpdateIssueBoard(t *testing.T) {
Milestone: &Milestone{
ID: 44,
IID: 1,
ProjectID: 0,
GroupID: 5,
Title: "Group Milestone",
Description: "Group Milestone Desc",
State: "active",
Expand Down Expand Up @@ -580,6 +580,7 @@ func TestGroupIssueBoardsService_CreateGroupIssueBoardList(t *testing.T) {
Milestone: &Milestone{
ID: 7,
IID: 3,
GroupID: 12,
Title: "Milestone with due date",
Description: "",
State: "active",
Expand Down
73 changes: 73 additions & 0 deletions issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,76 @@ func TestGetIssueParticipants(t *testing.T) {
t.Errorf("Issues.GetIssueParticipants returned %+v, want %+v", issueParticipants, want)
}
}

func TestGetIssueMilestone(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/projects/1/issues/5", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}],"merge_requests_count": 1,
"milestone": {"due_date": null, "project_id": 1, "state": "closed", "description": "test", "iid": 3, "id": 11, "title": "v3.0"}}`)
})

issue, _, err := client.Issues.GetIssue("1", 5)
if err != nil {
log.Fatal(err)
}

want := &Issue{
ID: 1,
Description: "This is test project",
Author: &IssueAuthor{ID: 1, Name: "snehal"},
Assignees: []*IssueAssignee{{ID: 1}},
MergeRequestCount: 1,
Milestone: &Milestone{
DueDate: nil,
ProjectID: 1,
State: "closed",
Description: "test",
IID: 3,
ID: 11,
Title: "v3.0",
},
}

if !reflect.DeepEqual(want, issue) {
t.Errorf("Issues.GetIssue returned %+v, want %+v", issue, want)
}
}

// See issue #1749 - Issue with a group milestone
func TestGetIssueGroupMilestone(t *testing.T) {
mux, client := setup(t)

mux.HandleFunc("/api/v4/projects/1/issues/5", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}],"merge_requests_count": 1,
"milestone": {"due_date": null, "group_id": 13, "state": "closed", "description": "test", "iid": 3, "id": 11, "title": "v3.0"}}`)
})

issue, _, err := client.Issues.GetIssue("1", 5)
if err != nil {
log.Fatal(err)
}

want := &Issue{
ID: 1,
Description: "This is test project",
Author: &IssueAuthor{ID: 1, Name: "snehal"},
Assignees: []*IssueAssignee{{ID: 1}},
MergeRequestCount: 1,
Milestone: &Milestone{
DueDate: nil,
GroupID: 13,
State: "closed",
Description: "test",
IID: 3,
ID: 11,
Title: "v3.0",
},
}

if !reflect.DeepEqual(want, issue) {
t.Errorf("Issues.GetIssue returned %+v, want %+v", issue, want)
}
}
1 change: 1 addition & 0 deletions milestones.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type MilestonesService struct {
type Milestone struct {
ID int `json:"id"`
IID int `json:"iid"`
GroupID int `json:"group_id"`
ProjectID int `json:"project_id"`
Title string `json:"title"`
Description string `json:"description"`
Expand Down

0 comments on commit a843ebc

Please sign in to comment.