mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-08-06 22:13:02 +02:00
Add missing affects and fix versions fields to issue fields (#209)
Add missing affects and fix versions fields to issue fields
This commit is contained in:
14
issue.go
14
issue.go
@ -128,6 +128,7 @@ type IssueFields struct {
|
|||||||
IssueLinks []*IssueLink `json:"issuelinks,omitempty" structs:"issuelinks,omitempty"`
|
IssueLinks []*IssueLink `json:"issuelinks,omitempty" structs:"issuelinks,omitempty"`
|
||||||
Comments *Comments `json:"comment,omitempty" structs:"comment,omitempty"`
|
Comments *Comments `json:"comment,omitempty" structs:"comment,omitempty"`
|
||||||
FixVersions []*FixVersion `json:"fixVersions,omitempty" structs:"fixVersions,omitempty"`
|
FixVersions []*FixVersion `json:"fixVersions,omitempty" structs:"fixVersions,omitempty"`
|
||||||
|
AffectsVersions []*AffectsVersion `json:"versions,omitempty" structs:"versions,omitempty"`
|
||||||
Labels []string `json:"labels,omitempty" structs:"labels,omitempty"`
|
Labels []string `json:"labels,omitempty" structs:"labels,omitempty"`
|
||||||
Subtasks []*Subtasks `json:"subtasks,omitempty" structs:"subtasks,omitempty"`
|
Subtasks []*Subtasks `json:"subtasks,omitempty" structs:"subtasks,omitempty"`
|
||||||
Attachments []*Attachment `json:"attachment,omitempty" structs:"attachment,omitempty"`
|
Attachments []*Attachment `json:"attachment,omitempty" structs:"attachment,omitempty"`
|
||||||
@ -464,16 +465,21 @@ type Comment struct {
|
|||||||
|
|
||||||
// FixVersion represents a software release in which an issue is fixed.
|
// FixVersion represents a software release in which an issue is fixed.
|
||||||
type FixVersion struct {
|
type FixVersion struct {
|
||||||
Archived *bool `json:"archived,omitempty" structs:"archived,omitempty"`
|
Self string `json:"self,omitempty" structs:"self,omitempty"`
|
||||||
ID string `json:"id,omitempty" structs:"id,omitempty"`
|
ID string `json:"id,omitempty" structs:"id,omitempty"`
|
||||||
Name string `json:"name,omitempty" structs:"name,omitempty"`
|
Name string `json:"name,omitempty" structs:"name,omitempty"`
|
||||||
ProjectID int `json:"projectId,omitempty" structs:"projectId,omitempty"`
|
Description string `json:"description,omitempty" structs:"name,omitempty"`
|
||||||
ReleaseDate string `json:"releaseDate,omitempty" structs:"releaseDate,omitempty"`
|
Archived *bool `json:"archived,omitempty" structs:"archived,omitempty"`
|
||||||
Released *bool `json:"released,omitempty" structs:"released,omitempty"`
|
Released *bool `json:"released,omitempty" structs:"released,omitempty"`
|
||||||
Self string `json:"self,omitempty" structs:"self,omitempty"`
|
ReleaseDate string `json:"releaseDate,omitempty" structs:"releaseDate,omitempty"`
|
||||||
UserReleaseDate string `json:"userReleaseDate,omitempty" structs:"userReleaseDate,omitempty"`
|
UserReleaseDate string `json:"userReleaseDate,omitempty" structs:"userReleaseDate,omitempty"`
|
||||||
|
ProjectID int `json:"projectId,omitempty" structs:"projectId,omitempty"` // Unlike other IDs, this is returned as a number
|
||||||
|
StartDate string `json:"startDate,omitempty" structs:"startDate,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AffectsVersion represents a software release which is affected by an issue.
|
||||||
|
type AffectsVersion Version
|
||||||
|
|
||||||
// CommentVisibility represents he visibility of a comment.
|
// CommentVisibility represents he visibility of a comment.
|
||||||
// E.g. Type could be "role" and Value "Administrators"
|
// E.g. Type could be "role" and Value "Administrators"
|
||||||
type CommentVisibility struct {
|
type CommentVisibility struct {
|
||||||
|
@ -937,6 +937,14 @@ func TestIssueFields_MarshalJSON_Success(t *testing.T) {
|
|||||||
ID: "10000",
|
ID: "10000",
|
||||||
Key: "EX",
|
Key: "EX",
|
||||||
},
|
},
|
||||||
|
AffectsVersions: []*AffectsVersion{
|
||||||
|
&AffectsVersion{
|
||||||
|
ID: "10705",
|
||||||
|
Name: "2.1.0-rc3",
|
||||||
|
Self: "http://www.example.com/jira/rest/api/2/version/10705",
|
||||||
|
ReleaseDate: "2018-09-30",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := json.Marshal(i)
|
bytes, err := json.Marshal(i)
|
||||||
@ -1428,3 +1436,35 @@ func TestIssueService_Get_Fields_Changelog(t *testing.T) {
|
|||||||
t.Errorf("Expected CreatedTime func return %v time, %v got", tm, ct)
|
t.Errorf("Expected CreatedTime func return %v time, %v got", tm, ct)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func TestIssueService_Get_Fields_AffectsVersions(t *testing.T) {
|
||||||
|
setup()
|
||||||
|
defer teardown()
|
||||||
|
testMux.HandleFunc("/rest/api/2/issue/10002", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
testMethod(t, r, "GET")
|
||||||
|
testRequestURL(t, r, "/rest/api/2/issue/10002")
|
||||||
|
|
||||||
|
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"}]}}`)
|
||||||
|
})
|
||||||
|
|
||||||
|
issue, _, err := testClient.Issue.Get("10002", nil)
|
||||||
|
if issue == nil {
|
||||||
|
t.Error("Expected issue. Issue is nil")
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(issue.Fields.AffectsVersions, []*AffectsVersion{
|
||||||
|
{
|
||||||
|
ID: "10705",
|
||||||
|
Name: "2.1.0-rc3",
|
||||||
|
Self: "http://www.example.com/jira/rest/api/2/version/10705",
|
||||||
|
ReleaseDate: "2018-09-30",
|
||||||
|
Released: false,
|
||||||
|
Archived: false,
|
||||||
|
Description: "test description",
|
||||||
|
},
|
||||||
|
}) {
|
||||||
|
t.Error("Expected AffectsVersions for the returned issue")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("Error given: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user