mirror of
https://github.com/interviewstreet/go-jira.git
synced 2025-03-21 21:07:03 +02:00
Cleaning a bunch of go vet issues
This commit is contained in:
parent
78dbcf28a8
commit
56d87db29c
@ -121,7 +121,7 @@ func (s *AuthenticationService) Authenticated() bool {
|
|||||||
// client anymore
|
// client anymore
|
||||||
func (s *AuthenticationService) Logout() error {
|
func (s *AuthenticationService) Logout() error {
|
||||||
if s.authType != authTypeSession || s.client.session == nil {
|
if s.authType != authTypeSession || s.client.session == nil {
|
||||||
return fmt.Errorf("No user is authenticated yet.")
|
return fmt.Errorf("no user is authenticated")
|
||||||
}
|
}
|
||||||
|
|
||||||
apiEndpoint := "rest/auth/1/session"
|
apiEndpoint := "rest/auth/1/session"
|
||||||
|
49
issue.go
49
issue.go
@ -388,17 +388,18 @@ type Worklog struct {
|
|||||||
// WorklogRecord represents one entry of a Worklog
|
// WorklogRecord represents one entry of a Worklog
|
||||||
type WorklogRecord struct {
|
type WorklogRecord struct {
|
||||||
Self string `json:"self,omitempty" structs:"self,omitempty"`
|
Self string `json:"self,omitempty" structs:"self,omitempty"`
|
||||||
Author *User `json:"author,omitempty" structs:"author,omitempty"`
|
Author *User `json:"author,omitempty" structs:"author,omitempty"`
|
||||||
UpdateAuthor *User `json:"updateAuthor,omitempty" structs:"updateAuthor,omitempty"`
|
UpdateAuthor *User `json:"updateAuthor,omitempty" structs:"updateAuthor,omitempty"`
|
||||||
Comment string `json:"comment,omitempty" structs:"comment,omitempty"`
|
Comment string `json:"comment,omitempty" structs:"comment,omitempty"`
|
||||||
Created *Time `json:"created,omitempty" structs:"created,omitempty"`
|
Created *Time `json:"created,omitempty" structs:"created,omitempty"`
|
||||||
Updated *Time `json:"updated,omitempty" structs:"updated,omitempty"`
|
Updated *Time `json:"updated,omitempty" structs:"updated,omitempty"`
|
||||||
Started *Time `json:"started,omitempty" structs:"started,omitempty"`
|
Started *Time `json:"started,omitempty" structs:"started,omitempty"`
|
||||||
TimeSpent string `json:"timeSpent,omitempty" structs:"timeSpent,omitempty"`
|
TimeSpent string `json:"timeSpent,omitempty" structs:"timeSpent,omitempty"`
|
||||||
TimeSpentSeconds int `json:"timeSpentSeconds,omitempty" structs:"timeSpentSeconds,omitempty"`
|
TimeSpentSeconds int `json:"timeSpentSeconds,omitempty" structs:"timeSpentSeconds,omitempty"`
|
||||||
ID string `json:"id,omitempty" structs:"id,omitempty"`
|
ID string `json:"id,omitempty" structs:"id,omitempty"`
|
||||||
IssueID string `json:"issueId,omitempty" structs:"issueId,omitempty"`
|
IssueID string `json:"issueId,omitempty" structs:"issueId,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TimeTracking represents the timetracking fields of a JIRA issue.
|
// TimeTracking represents the timetracking fields of a JIRA issue.
|
||||||
type TimeTracking struct {
|
type TimeTracking struct {
|
||||||
OriginalEstimate string `json:"originalEstimate,omitempty" structs:"originalEstimate,omitempty"`
|
OriginalEstimate string `json:"originalEstimate,omitempty" structs:"originalEstimate,omitempty"`
|
||||||
@ -674,11 +675,11 @@ func (s *IssueService) Update(issue *Issue) (*Issue, *Response, error) {
|
|||||||
return &ret, resp, nil
|
return &ret, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update updates an issue from a JSON representation. The issue is found by key.
|
// UpdateIssue updates an issue from a JSON representation. The issue is found by key.
|
||||||
//
|
//
|
||||||
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
|
// https://docs.atlassian.com/jira/REST/7.4.0/#api/2/issue-editIssue
|
||||||
func (s *IssueService) UpdateIssue(jiraId string, data map[string]interface{}) (*Response, error) {
|
func (s *IssueService) UpdateIssue(jiraID string, data map[string]interface{}) (*Response, error) {
|
||||||
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", jiraId)
|
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%v", jiraID)
|
||||||
req, err := s.client.NewRequest("PUT", apiEndpoint, data)
|
req, err := s.client.NewRequest("PUT", apiEndpoint, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -741,20 +742,20 @@ func (s *IssueService) UpdateComment(issueID string, comment *Comment) (*Comment
|
|||||||
//
|
//
|
||||||
// https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-worklog-post
|
// https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-worklog-post
|
||||||
func (s *IssueService) AddWorklogRecord(issueID string, record *WorklogRecord) (*WorklogRecord, *Response, error) {
|
func (s *IssueService) AddWorklogRecord(issueID string, record *WorklogRecord) (*WorklogRecord, *Response, error) {
|
||||||
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/worklog", issueID)
|
apiEndpoint := fmt.Sprintf("rest/api/2/issue/%s/worklog", issueID)
|
||||||
req, err := s.client.NewRequest("POST", apiEndpoint, record)
|
req, err := s.client.NewRequest("POST", apiEndpoint, record)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
responseRecord := new(WorklogRecord)
|
responseRecord := new(WorklogRecord)
|
||||||
resp, err := s.client.Do(req, responseRecord)
|
resp, err := s.client.Do(req, responseRecord)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
jerr := NewJiraError(resp, err)
|
jerr := NewJiraError(resp, err)
|
||||||
return nil, resp, jerr
|
return nil, resp, jerr
|
||||||
}
|
}
|
||||||
|
|
||||||
return responseRecord, resp, nil
|
return responseRecord, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLink adds a link between two issues.
|
// AddLink adds a link between two issues.
|
||||||
@ -949,7 +950,7 @@ func InitIssueWithMetaAndFields(metaProject *MetaProject, metaIssuetype *MetaIss
|
|||||||
for key, value := range fieldsConfig {
|
for key, value := range fieldsConfig {
|
||||||
jiraKey, found := allFields[key]
|
jiraKey, found := allFields[key]
|
||||||
if !found {
|
if !found {
|
||||||
return nil, fmt.Errorf("Key %s is not found in the list of fields.", key)
|
return nil, fmt.Errorf("key %s is not found in the list of fields", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
valueType, err := metaIssuetype.Fields.String(jiraKey + "/schema/type")
|
valueType, err := metaIssuetype.Fields.String(jiraKey + "/schema/type")
|
||||||
@ -1030,9 +1031,9 @@ func (s *IssueService) Delete(issueID string) (*Response, error) {
|
|||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-getIssueWatchers
|
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-getIssueWatchers
|
||||||
func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
|
func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
|
||||||
watchesApiEndPoint := fmt.Sprintf("rest/api/2/issue/%s/watchers", issueID)
|
watchesAPIEndpoint := fmt.Sprintf("rest/api/2/issue/%s/watchers", issueID)
|
||||||
|
|
||||||
req, err := s.client.NewRequest("GET", watchesApiEndPoint, nil)
|
req, err := s.client.NewRequest("GET", watchesAPIEndpoint, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -1056,7 +1057,7 @@ func (s *IssueService) GetWatchers(issueID string) (*[]User, *Response, error) {
|
|||||||
return &result, resp, nil
|
return &result, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetWatcher adds watcher to the given issue
|
// AddWatcher adds watcher to the given issue
|
||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-addWatcher
|
// JIRA API docs: https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-addWatcher
|
||||||
func (s *IssueService) AddWatcher(issueID string, userName string) (*Response, error) {
|
func (s *IssueService) AddWatcher(issueID string, userName string) (*Response, error) {
|
||||||
|
@ -112,11 +112,11 @@ func TestIssueService_UpdateIssue(t *testing.T) {
|
|||||||
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
})
|
})
|
||||||
jId := "PROJ-9001"
|
jID := "PROJ-9001"
|
||||||
i := make(map[string]interface{})
|
i := make(map[string]interface{})
|
||||||
fields := make(map[string]interface{})
|
fields := make(map[string]interface{})
|
||||||
i["fields"] = fields
|
i["fields"] = fields
|
||||||
resp, err := testClient.Issue.UpdateIssue(jId, i)
|
resp, err := testClient.Issue.UpdateIssue(jID, i)
|
||||||
if resp == nil {
|
if resp == nil {
|
||||||
t.Error("Expected resp. resp is nil")
|
t.Error("Expected resp. resp is nil")
|
||||||
}
|
}
|
||||||
@ -182,25 +182,25 @@ func TestIssueService_UpdateComment(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIssueService_AddWorklogRecord(t *testing.T) {
|
func TestIssueService_AddWorklogRecord(t *testing.T) {
|
||||||
setup()
|
setup()
|
||||||
defer teardown()
|
defer teardown()
|
||||||
testMux.HandleFunc("/rest/api/2/issue/10000/worklog", func(w http.ResponseWriter, r *http.Request) {
|
testMux.HandleFunc("/rest/api/2/issue/10000/worklog", func(w http.ResponseWriter, r *http.Request) {
|
||||||
testMethod(t, r, "POST")
|
testMethod(t, r, "POST")
|
||||||
testRequestURL(t, r, "/rest/api/2/issue/10000/worklog")
|
testRequestURL(t, r, "/rest/api/2/issue/10000/worklog")
|
||||||
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
w.WriteHeader(http.StatusCreated)
|
||||||
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000","author":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"updateAuthor":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"comment":"I did some work here.","updated":"2018-02-14T22:14:46.003+0000","visibility":{"type":"group","value":"jira-developers"},"started":"2018-02-14T22:14:46.003+0000","timeSpent":"3h 20m","timeSpentSeconds":12000,"id":"100028","issueId":"10002"}`)
|
fmt.Fprint(w, `{"self":"http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000","author":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"updateAuthor":{"self":"http://www.example.com/jira/rest/api/2/user?username=fred","name":"fred","displayName":"Fred F. User","active":false},"comment":"I did some work here.","updated":"2018-02-14T22:14:46.003+0000","visibility":{"type":"group","value":"jira-developers"},"started":"2018-02-14T22:14:46.003+0000","timeSpent":"3h 20m","timeSpentSeconds":12000,"id":"100028","issueId":"10002"}`)
|
||||||
})
|
})
|
||||||
r := &WorklogRecord{
|
r := &WorklogRecord{
|
||||||
TimeSpent: "1h",
|
TimeSpent: "1h",
|
||||||
}
|
}
|
||||||
record, _, err := testClient.Issue.AddWorklogRecord("10000", r)
|
record, _, err := testClient.Issue.AddWorklogRecord("10000", r)
|
||||||
if record == nil {
|
if record == nil {
|
||||||
t.Error("Expected Record. Record is nil")
|
t.Error("Expected Record. Record is nil")
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Error given: %s", err)
|
t.Errorf("Error given: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssueService_AddLink(t *testing.T) {
|
func TestIssueService_AddLink(t *testing.T) {
|
||||||
|
@ -16,7 +16,7 @@ type CreateMetaInfo struct {
|
|||||||
// MetaProject is the meta information about a project returned from createmeta api
|
// MetaProject is the meta information about a project returned from createmeta api
|
||||||
type MetaProject struct {
|
type MetaProject struct {
|
||||||
Expand string `json:"expand,omitempty"`
|
Expand string `json:"expand,omitempty"`
|
||||||
Self string `json:"self, omitempty"`
|
Self string `json:"self,omitempty"`
|
||||||
Id string `json:"id,omitempty"`
|
Id string `json:"id,omitempty"`
|
||||||
Key string `json:"key,omitempty"`
|
Key string `json:"key,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
@ -79,7 +79,7 @@ func (s *ProjectService) GetList() (*ProjectList, *Response, error) {
|
|||||||
return s.ListWithOptions(&GetQueryOptions{})
|
return s.ListWithOptions(&GetQueryOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetList gets all projects form JIRA with optional query params, like &GetQueryOptions{Expand: "issueTypes"} to get
|
// ListWithOptions gets all projects form JIRA with optional query params, like &GetQueryOptions{Expand: "issueTypes"} to get
|
||||||
// a list of all projects and their supported issuetypes
|
// a list of all projects and their supported issuetypes
|
||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getAllProjects
|
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#api/2/project-getAllProjects
|
||||||
|
2
user.go
2
user.go
@ -99,7 +99,7 @@ func (s *UserService) GetGroups(username string) (*[]UserGroup, *Response, error
|
|||||||
return userGroups, resp, nil
|
return userGroups, resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finds user info from JIRA:
|
// Find searches for user info from JIRA:
|
||||||
// It can find users by email, username or name
|
// It can find users by email, username or name
|
||||||
//
|
//
|
||||||
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/user-findUsers
|
// JIRA API docs: https://docs.atlassian.com/jira/REST/cloud/#api/2/user-findUsers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user