Skip to content

Commit b1589c4

Browse files
committed
Add 'affects versions' to issue fields
1 parent 18969b0 commit b1589c4

2 files changed

Lines changed: 80 additions & 36 deletions

File tree

issue.go

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -101,42 +101,43 @@ type IssueFields struct {
101101
// * "workratio": -1,
102102
// * "lastViewed": null,
103103
// * "environment": null,
104-
Expand string `json:"expand,omitempty" structs:"expand,omitempty"`
105-
Type IssueType `json:"issuetype,omitempty" structs:"issuetype,omitempty"`
106-
Project Project `json:"project,omitempty" structs:"project,omitempty"`
107-
Resolution *Resolution `json:"resolution,omitempty" structs:"resolution,omitempty"`
108-
Priority *Priority `json:"priority,omitempty" structs:"priority,omitempty"`
109-
Resolutiondate Time `json:"resolutiondate,omitempty" structs:"resolutiondate,omitempty"`
110-
Created Time `json:"created,omitempty" structs:"created,omitempty"`
111-
Duedate Date `json:"duedate,omitempty" structs:"duedate,omitempty"`
112-
Watches *Watches `json:"watches,omitempty" structs:"watches,omitempty"`
113-
Assignee *User `json:"assignee,omitempty" structs:"assignee,omitempty"`
114-
Updated Time `json:"updated,omitempty" structs:"updated,omitempty"`
115-
Description string `json:"description,omitempty" structs:"description,omitempty"`
116-
Summary string `json:"summary,omitempty" structs:"summary,omitempty"`
117-
Creator *User `json:"Creator,omitempty" structs:"Creator,omitempty"`
118-
Reporter *User `json:"reporter,omitempty" structs:"reporter,omitempty"`
119-
Components []*Component `json:"components,omitempty" structs:"components,omitempty"`
120-
Status *Status `json:"status,omitempty" structs:"status,omitempty"`
121-
Progress *Progress `json:"progress,omitempty" structs:"progress,omitempty"`
122-
AggregateProgress *Progress `json:"aggregateprogress,omitempty" structs:"aggregateprogress,omitempty"`
123-
TimeTracking *TimeTracking `json:"timetracking,omitempty" structs:"timetracking,omitempty"`
124-
TimeSpent int `json:"timespent,omitempty" structs:"timespent,omitempty"`
125-
TimeEstimate int `json:"timeestimate,omitempty" structs:"timeestimate,omitempty"`
126-
TimeOriginalEstimate int `json:"timeoriginalestimate,omitempty" structs:"timeoriginalestimate,omitempty"`
127-
Worklog *Worklog `json:"worklog,omitempty" structs:"worklog,omitempty"`
128-
IssueLinks []*IssueLink `json:"issuelinks,omitempty" structs:"issuelinks,omitempty"`
129-
Comments *Comments `json:"comment,omitempty" structs:"comment,omitempty"`
130-
FixVersions []*FixVersion `json:"fixVersions,omitempty" structs:"fixVersions,omitempty"`
131-
Labels []string `json:"labels,omitempty" structs:"labels,omitempty"`
132-
Subtasks []*Subtasks `json:"subtasks,omitempty" structs:"subtasks,omitempty"`
133-
Attachments []*Attachment `json:"attachment,omitempty" structs:"attachment,omitempty"`
134-
Epic *Epic `json:"epic,omitempty" structs:"epic,omitempty"`
135-
Sprint *Sprint `json:"sprint,omitempty" structs:"sprint,omitempty"`
136-
Parent *Parent `json:"parent,omitempty" structs:"parent,omitempty"`
137-
AggregateTimeOriginalEstimate int `json:"aggregatetimeoriginalestimate,omitempty" structs:"aggregatetimeoriginalestimate,omitempty"`
138-
AggregateTimeSpent int `json:"aggregatetimespent,omitempty" structs:"aggregatetimespent,omitempty"`
139-
AggregateTimeEstimate int `json:"aggregatetimeestimate,omitempty" structs:"aggregatetimeestimate,omitempty"`
104+
Expand string `json:"expand,omitempty" structs:"expand,omitempty"`
105+
Type IssueType `json:"issuetype,omitempty" structs:"issuetype,omitempty"`
106+
Project Project `json:"project,omitempty" structs:"project,omitempty"`
107+
Resolution *Resolution `json:"resolution,omitempty" structs:"resolution,omitempty"`
108+
Priority *Priority `json:"priority,omitempty" structs:"priority,omitempty"`
109+
Resolutiondate Time `json:"resolutiondate,omitempty" structs:"resolutiondate,omitempty"`
110+
Created Time `json:"created,omitempty" structs:"created,omitempty"`
111+
Duedate Date `json:"duedate,omitempty" structs:"duedate,omitempty"`
112+
Watches *Watches `json:"watches,omitempty" structs:"watches,omitempty"`
113+
Assignee *User `json:"assignee,omitempty" structs:"assignee,omitempty"`
114+
Updated Time `json:"updated,omitempty" structs:"updated,omitempty"`
115+
Description string `json:"description,omitempty" structs:"description,omitempty"`
116+
Summary string `json:"summary,omitempty" structs:"summary,omitempty"`
117+
Creator *User `json:"Creator,omitempty" structs:"Creator,omitempty"`
118+
Reporter *User `json:"reporter,omitempty" structs:"reporter,omitempty"`
119+
Components []*Component `json:"components,omitempty" structs:"components,omitempty"`
120+
Status *Status `json:"status,omitempty" structs:"status,omitempty"`
121+
Progress *Progress `json:"progress,omitempty" structs:"progress,omitempty"`
122+
AggregateProgress *Progress `json:"aggregateprogress,omitempty" structs:"aggregateprogress,omitempty"`
123+
TimeTracking *TimeTracking `json:"timetracking,omitempty" structs:"timetracking,omitempty"`
124+
TimeSpent int `json:"timespent,omitempty" structs:"timespent,omitempty"`
125+
TimeEstimate int `json:"timeestimate,omitempty" structs:"timeestimate,omitempty"`
126+
TimeOriginalEstimate int `json:"timeoriginalestimate,omitempty" structs:"timeoriginalestimate,omitempty"`
127+
Worklog *Worklog `json:"worklog,omitempty" structs:"worklog,omitempty"`
128+
IssueLinks []*IssueLink `json:"issuelinks,omitempty" structs:"issuelinks,omitempty"`
129+
Comments *Comments `json:"comment,omitempty" structs:"comment,omitempty"`
130+
FixVersions []*FixVersion `json:"fixVersions,omitempty" structs:"fixVersions,omitempty"`
131+
AffectsVersions []*AffectsVersion `json:"versions,omitempty" structs:"versions,omitempty"`
132+
Labels []string `json:"labels,omitempty" structs:"labels,omitempty"`
133+
Subtasks []*Subtasks `json:"subtasks,omitempty" structs:"subtasks,omitempty"`
134+
Attachments []*Attachment `json:"attachment,omitempty" structs:"attachment,omitempty"`
135+
Epic *Epic `json:"epic,omitempty" structs:"epic,omitempty"`
136+
Sprint *Sprint `json:"sprint,omitempty" structs:"sprint,omitempty"`
137+
Parent *Parent `json:"parent,omitempty" structs:"parent,omitempty"`
138+
AggregateTimeOriginalEstimate int `json:"aggregatetimeoriginalestimate,omitempty" structs:"aggregatetimeoriginalestimate,omitempty"`
139+
AggregateTimeSpent int `json:"aggregatetimespent,omitempty" structs:"aggregatetimespent,omitempty"`
140+
AggregateTimeEstimate int `json:"aggregatetimeestimate,omitempty" structs:"aggregatetimeestimate,omitempty"`
140141
Unknowns tcontainer.MarshalMap
141142
}
142143

@@ -476,6 +477,9 @@ type FixVersion struct {
476477
StartDate string `json:"startDate,omitempty" structs:"startDate,omitempty"`
477478
}
478479

480+
// AffectsVersion represents a software release which is affected by an issue.
481+
type AffectsVersion Version
482+
479483
// CommentVisibility represents he visibility of a comment.
480484
// E.g. Type could be "role" and Value "Administrators"
481485
type CommentVisibility struct {

issue_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,14 @@ func TestIssueFields_MarshalJSON_Success(t *testing.T) {
937937
ID: "10000",
938938
Key: "EX",
939939
},
940+
AffectsVersions: []*AffectsVersion{
941+
&AffectsVersion{
942+
ID: "10705",
943+
Name: "2.1.0-rc3",
944+
Self: "http://www.example.com/jira/rest/api/2/version/10705",
945+
ReleaseDate: "2018-09-30",
946+
},
947+
},
940948
}
941949

942950
bytes, err := json.Marshal(i)
@@ -1428,3 +1436,35 @@ func TestIssueService_Get_Fields_Changelog(t *testing.T) {
14281436
t.Errorf("Expected CreatedTime func return %v time, %v got", tm, ct)
14291437
}
14301438
}
1439+
func TestIssueService_Get_Fields_AffectsVersions(t *testing.T) {
1440+
setup()
1441+
defer teardown()
1442+
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
1443+
testMethod(t, r, "GET")
1444+
testRequestURL(t, r, "/rest/api/2/issue/10002")
1445+
1446+
fmt.Fprint(w, `{"fields":{"versions":[{"self":"http://www.example.com/jira/rest/api/2/version/10705","id":"10705","description":"test description","name":"2.1.0-rc3","archived":false,"released":false,"releaseDate":"2018-09-30"}]}}`)
1447+
})
1448+
1449+
issue, _, err := testClient.Issue.Get("10002", nil)
1450+
if issue == nil {
1451+
t.Error("Expected issue. Issue is nil")
1452+
}
1453+
if !reflect.DeepEqual(issue.Fields.AffectsVersions, []*AffectsVersion{
1454+
{
1455+
ID: "10705",
1456+
Name: "2.1.0-rc3",
1457+
Self: "http://www.example.com/jira/rest/api/2/version/10705",
1458+
ReleaseDate: "2018-09-30",
1459+
Released: false,
1460+
Archived: false,
1461+
Description: "test description",
1462+
},
1463+
}) {
1464+
t.Error("Expected AffectsVersions for the returned issue")
1465+
}
1466+
1467+
if err != nil {
1468+
t.Errorf("Error given: %s", err)
1469+
}
1470+
}

0 commit comments

Comments
 (0)