1
0
mirror of https://github.com/interviewstreet/go-jira.git synced 2025-06-04 23:07:35 +02:00

Fixed a few fmt and debug outputs

This commit is contained in:
Andy Grunwald 2016-10-03 13:33:46 +02:00
parent 8d3b47871f
commit 31508ce192
6 changed files with 95 additions and 119 deletions

View File

@ -84,9 +84,6 @@ func (s *AuthenticationService) Authenticated() bool {
// //
// JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#auth/1/session // JIRA API docs: https://docs.atlassian.com/jira/REST/latest/#auth/1/session
func (s *AuthenticationService) Logout() error { func (s *AuthenticationService) Logout() error {
if s == nil {
return fmt.Errorf("Authenticaiton Service is not instantiated")
}
if s.client.session == nil { if s.client.session == nil {
return fmt.Errorf("No user is authenticated yet.") return fmt.Errorf("No user is authenticated yet.")
} }
@ -96,7 +93,7 @@ func (s *AuthenticationService) Logout() error {
if err != nil { if err != nil {
return fmt.Errorf("Creating the request to log the user out failed : %s", err) return fmt.Errorf("Creating the request to log the user out failed : %s", err)
} }
//var dump interface{}
resp, err := s.client.Do(req, nil) resp, err := s.client.Do(req, nil)
if err != nil { if err != nil {
return fmt.Errorf("Error sending the logout request: %s", err) return fmt.Errorf("Error sending the logout request: %s", err)
@ -105,7 +102,7 @@ func (s *AuthenticationService) Logout() error {
return fmt.Errorf("The logout was unsuccessful with status %d", resp.StatusCode) return fmt.Errorf("The logout was unsuccessful with status %d", resp.StatusCode)
} }
// if logout successfull, delete session // If logout successfull, delete session
s.client.session = nil s.client.session = nil
return nil return nil
@ -151,5 +148,4 @@ func (s *AuthenticationService) GetCurrentUser() (*Session, error) {
} }
return ret, nil return ret, nil
} }

View File

@ -121,7 +121,6 @@ func TestAithenticationService_GetUserInfo_AccessForbidden_Fail(t *testing.T) {
if err == nil { if err == nil {
t.Errorf("Non nil error expect, recieved nil") t.Errorf("Non nil error expect, recieved nil")
} }
} }
func TestAuthenticationService_GetUserInfo_NonOkStatusCode_Fail(t *testing.T) { func TestAuthenticationService_GetUserInfo_NonOkStatusCode_Fail(t *testing.T) {
@ -178,7 +177,7 @@ func TestAuthenticationService_GetUserInfo_Success(t *testing.T) {
testUserInfo := new(Session) testUserInfo := new(Session)
testUserInfo.Name = "foo" testUserInfo.Name = "foo"
testUserInfo.Self = "https://tasks.trivago.com/rest/api/latest/user?username=foo" testUserInfo.Self = "https://my.jira.com/rest/api/latest/user?username=foo"
testUserInfo.LoginInfo.FailedLoginCount = 12 testUserInfo.LoginInfo.FailedLoginCount = 12
testUserInfo.LoginInfo.LastFailedLoginTime = "2016-09-06T16:41:23.949+0200" testUserInfo.LoginInfo.LastFailedLoginTime = "2016-09-06T16:41:23.949+0200"
testUserInfo.LoginInfo.LoginCount = 357 testUserInfo.LoginInfo.LoginCount = 357
@ -205,9 +204,8 @@ func TestAuthenticationService_GetUserInfo_Success(t *testing.T) {
if r.Method == "GET" { if r.Method == "GET" {
testMethod(t, r, "GET") testMethod(t, r, "GET")
testRequestURL(t, r, "/rest/auth/1/session") testRequestURL(t, r, "/rest/auth/1/session")
fmt.Fprint(w, `{"self":"https://tasks.trivago.com/rest/api/latest/user?username=foo","name":"foo","loginInfo":{"failedLoginCount":12,"loginCount":357,"lastFailedLoginTime":"2016-09-06T16:41:23.949+0200","previousLoginTime":"2016-09-07T11:36:23.476+0200"}}`) fmt.Fprint(w, `{"self":"https://my.jira.com/rest/api/latest/user?username=foo","name":"foo","loginInfo":{"failedLoginCount":12,"loginCount":357,"lastFailedLoginTime":"2016-09-06T16:41:23.949+0200","previousLoginTime":"2016-09-07T11:36:23.476+0200"}}`)
} }
}) })
testClient.Authentication.AcquireSessionCookie("foo", "bar") testClient.Authentication.AcquireSessionCookie("foo", "bar")
@ -249,7 +247,6 @@ func TestAuthenticationService_Logout_Success(t *testing.T) {
// return 204 // return 204
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
} }
}) })
testClient.Authentication.AcquireSessionCookie("foo", "bar") testClient.Authentication.AcquireSessionCookie("foo", "bar")
@ -258,7 +255,6 @@ func TestAuthenticationService_Logout_Success(t *testing.T) {
if err != nil { if err != nil {
t.Errorf("Expected nil error, got %s", err) t.Errorf("Expected nil error, got %s", err)
} }
} }
func TestAuthenticationService_Logout_FailWithoutLogin(t *testing.T) { func TestAuthenticationService_Logout_FailWithoutLogin(t *testing.T) {
@ -270,7 +266,6 @@ func TestAuthenticationService_Logout_FailWithoutLogin(t *testing.T) {
// 401 // 401
w.WriteHeader(http.StatusUnauthorized) w.WriteHeader(http.StatusUnauthorized)
} }
}) })
err := testClient.Authentication.Logout() err := testClient.Authentication.Logout()
if err == nil { if err == nil {

View File

@ -4,14 +4,15 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/fatih/structs"
"github.com/trivago/tgo/tcontainer"
"io" "io"
"mime/multipart" "mime/multipart"
"net/url" "net/url"
"reflect" "reflect"
"strings" "strings"
"time" "time"
"github.com/fatih/structs"
"github.com/trivago/tgo/tcontainer"
) )
const ( const (
@ -102,6 +103,8 @@ type IssueFields struct {
Unknowns tcontainer.MarshalMap Unknowns tcontainer.MarshalMap
} }
// MarshalJSON is a custom JSON marshal function for the IssueFields structs.
// It handles JIRA custom fields and maps those from / to "Unknowns" key.
func (i *IssueFields) MarshalJSON() ([]byte, error) { func (i *IssueFields) MarshalJSON() ([]byte, error) {
m := structs.Map(i) m := structs.Map(i)
unknowns, okay := m["Unknowns"] unknowns, okay := m["Unknowns"]
@ -115,6 +118,8 @@ func (i *IssueFields) MarshalJSON() ([]byte, error) {
return json.Marshal(m) return json.Marshal(m)
} }
// UnmarshalJSON is a custom JSON marshal function for the IssueFields structs.
// It handles JIRA custom fields and maps those from / to "Unknowns" key.
func (i *IssueFields) UnmarshalJSON(data []byte) error { func (i *IssueFields) UnmarshalJSON(data []byte) error {
// Do the normal unmarshalling first // Do the normal unmarshalling first

View File

@ -494,59 +494,59 @@ func TestIssueFields_TestMarshalJSON_PopulateUnknownsSuccess(t *testing.T) {
data := `{ data := `{
"customfield_123":"test", "customfield_123":"test",
"description":"example bug report", "description":"example bug report",
"project":{ "project":{
"self":"http://www.example.com/jira/rest/api/2/project/EX", "self":"http://www.example.com/jira/rest/api/2/project/EX",
"id":"10000", "id":"10000",
"key":"EX", "key":"EX",
"name":"Example", "name":"Example",
"avatarUrls":{ "avatarUrls":{
"48x48":"http://www.example.com/jira/secure/projectavatar?size=large&pid=10000", "48x48":"http://www.example.com/jira/secure/projectavatar?size=large&pid=10000",
"24x24":"http://www.example.com/jira/secure/projectavatar?size=small&pid=10000", "24x24":"http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
"16x16":"http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000", "16x16":"http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
"32x32":"http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000" "32x32":"http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000"
}, },
"projectCategory":{ "projectCategory":{
"self":"http://www.example.com/jira/rest/api/2/projectCategory/10000", "self":"http://www.example.com/jira/rest/api/2/projectCategory/10000",
"id":"10000", "id":"10000",
"name":"FIRST", "name":"FIRST",
"description":"First Project Category" "description":"First Project Category"
} }
}, },
"issuelinks":[ "issuelinks":[
{ {
"id":"10001", "id":"10001",
"type":{ "type":{
"id":"10000", "id":"10000",
"name":"Dependent", "name":"Dependent",
"inward":"depends on", "inward":"depends on",
"outward":"is depended by" "outward":"is depended by"
}, },
"outwardIssue":{ "outwardIssue":{
"id":"10004L", "id":"10004L",
"key":"PRJ-2", "key":"PRJ-2",
"self":"http://www.example.com/jira/rest/api/2/issue/PRJ-2", "self":"http://www.example.com/jira/rest/api/2/issue/PRJ-2",
"fields":{ "fields":{
"status":{ "status":{
"iconUrl":"http://www.example.com/jira//images/icons/statuses/open.png", "iconUrl":"http://www.example.com/jira//images/icons/statuses/open.png",
"name":"Open" "name":"Open"
} }
} }
} }
}, },
{ {
"id":"10002", "id":"10002",
"type":{ "type":{
"id":"10000", "id":"10000",
"name":"Dependent", "name":"Dependent",
"inward":"depends on", "inward":"depends on",
"outward":"is depended by" "outward":"is depended by"
}, },
"inwardIssue":{ "inwardIssue":{
"id":"10004", "id":"10004",
"key":"PRJ-3", "key":"PRJ-3",
"self":"http://www.example.com/jira/rest/api/2/issue/PRJ-3", "self":"http://www.example.com/jira/rest/api/2/issue/PRJ-3",
"fields":{ "fields":{
"status":{ "status":{
"iconUrl":"http://www.example.com/jira//images/icons/statuses/open.png", "iconUrl":"http://www.example.com/jira//images/icons/statuses/open.png",
"name":"Open" "name":"Open"
} }
@ -554,7 +554,7 @@ func TestIssueFields_TestMarshalJSON_PopulateUnknownsSuccess(t *testing.T) {
} }
} }
] ]
}` }`
i := new(IssueFields) i := new(IssueFields)
@ -573,18 +573,6 @@ func TestIssueFields_TestMarshalJSON_PopulateUnknownsSuccess(t *testing.T) {
} }
func TestIssueFields_MarshalJSON_Success(t *testing.T) { func TestIssueFields_MarshalJSON_Success(t *testing.T) {
/*
{
"customfield_123":"test",
"description":"example bug report",
"project":{
"self":"http://www.example.com/jira/rest/api/2/project/EX",
"id":"10000",
"key":"EX"
}
}
*/
i := &IssueFields{ i := &IssueFields{
Description: "example bug report", Description: "example bug report",
Unknowns: tcontainer.MarshalMap{ Unknowns: tcontainer.MarshalMap{
@ -612,5 +600,4 @@ func TestIssueFields_MarshalJSON_Success(t *testing.T) {
if !reflect.DeepEqual(i, recieved) { if !reflect.DeepEqual(i, recieved) {
t.Errorf("Recieved object different from expected") t.Errorf("Recieved object different from expected")
} }
} }

View File

@ -2,8 +2,9 @@ package jira
import ( import (
"fmt" "fmt"
"github.com/trivago/tgo/tcontainer"
"strings" "strings"
"github.com/trivago/tgo/tcontainer"
) )
// CreateMeta contains information about fields and their attributed to create a ticket. // CreateMeta contains information about fields and their attributed to create a ticket.
@ -49,7 +50,7 @@ func (s *IssueService) GetCreateMeta(projectkey string) (*CreateMetaInfo, *Respo
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
fmt.Println(req.URL)
meta := new(CreateMetaInfo) meta := new(CreateMetaInfo)
resp, err := s.client.Do(req, meta) resp, err := s.client.Do(req, meta)

View File

@ -10,31 +10,31 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
setup() setup()
defer teardown() defer teardown()
testApiEndpoint := "/rest/api/2/issue/createmeta" testAPIEndpoint := "/rest/api/2/issue/createmeta"
testMux.HandleFunc(testApiEndpoint, func(w http.ResponseWriter, r *http.Request) { testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET") testMethod(t, r, "GET")
testRequestURL(t, r, testApiEndpoint) testRequestURL(t, r, testAPIEndpoint)
fmt.Fprint(w, `{ fmt.Fprint(w, `{
"expand": "projects", "expand": "projects",
"projects": [{ "projects": [{
"expand": "issuetypes", "expand": "issuetypes",
"self": "https://tasks.trivago.com/rest/api/2/project/11300", "self": "https://my.jira.com/rest/api/2/project/11300",
"id": "11300", "id": "11300",
"key": "SOP", "key": "SPN",
"name": "DSE - Software Operations", "name": "Super Project Name",
"avatarUrls": { "avatarUrls": {
"48x48": "https://tasks.trivago.com/secure/projectavatar?pid=11300&avatarId=14405", "48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
"24x24": "https://tasks.trivago.com/secure/projectavatar?size=small&pid=11300&avatarId=14405", "24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
"16x16": "https://tasks.trivago.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405", "16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
"32x32": "https://tasks.trivago.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405" "32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
}, },
"issuetypes": [{ "issuetypes": [{
"self": "https://tasks.trivago.com/rest/api/2/issuetype/6", "self": "https://my.jira.com/rest/api/2/issuetype/6",
"id": "6", "id": "6",
"description": "An issue which ideally should be able to be completed in one step", "description": "An issue which ideally should be able to be completed in one step",
"iconUrl": "https://tasks.trivago.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype", "iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
"name": "Request", "name": "Request",
"subtask": false, "subtask": false,
"expand": "fields", "expand": "fields",
@ -63,10 +63,10 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
], ],
"allowedValues": [{ "allowedValues": [{
"self": "https://tasks.trivago.com/rest/api/2/issuetype/6", "self": "https://my.jira.com/rest/api/2/issuetype/6",
"id": "6", "id": "6",
"description": "An issue which ideally should be able to be completed in one step", "description": "An issue which ideally should be able to be completed in one step",
"iconUrl": "https://tasks.trivago.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype", "iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
"name": "Request", "name": "Request",
"subtask": false, "subtask": false,
"avatarId": 14006 "avatarId": 14006
@ -87,106 +87,106 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
"remove" "remove"
], ],
"allowedValues": [{ "allowedValues": [{
"self": "https://tasks.trivago.com/rest/api/2/component/14144", "self": "https://my.jira.com/rest/api/2/component/14144",
"id": "14144", "id": "14144",
"name": "Build automation", "name": "Build automation",
"description": "Jenkins, webhooks, etc." "description": "Jenkins, webhooks, etc."
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14149", "self": "https://my.jira.com/rest/api/2/component/14149",
"id": "14149", "id": "14149",
"name": "Caches and noSQL", "name": "Caches and noSQL",
"description": "Cassandra, Memcached, Redis, Twemproxy, Xcache" "description": "Cassandra, Memcached, Redis, Twemproxy, Xcache"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14152", "self": "https://my.jira.com/rest/api/2/component/14152",
"id": "14152", "id": "14152",
"name": "Cloud services", "name": "Cloud services",
"description": "AWS and similiar services" "description": "AWS and similiar services"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14147", "self": "https://my.jira.com/rest/api/2/component/14147",
"id": "14147", "id": "14147",
"name": "Code quality tools", "name": "Code quality tools",
"description": "Code sniffer, Arqtig, Sonar" "description": "Code sniffer, Sonar"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14156", "self": "https://my.jira.com/rest/api/2/component/14156",
"id": "14156", "id": "14156",
"name": "Configuration management and provisioning", "name": "Configuration management and provisioning",
"description": "Apache/PHP modules, Consul, Salt" "description": "Apache/PHP modules, Consul, Salt"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/13606", "self": "https://my.jira.com/rest/api/2/component/13606",
"id": "13606", "id": "13606",
"name": "Cronjobs", "name": "Cronjobs",
"description": "Cronjobs in general" "description": "Cronjobs in general"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14150", "self": "https://my.jira.com/rest/api/2/component/14150",
"id": "14150", "id": "14150",
"name": "Data pipelines and queues", "name": "Data pipelines and queues",
"description": "Gollum, Kafka, RabbitMq" "description": "Kafka, RabbitMq"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14159", "self": "https://my.jira.com/rest/api/2/component/14159",
"id": "14159", "id": "14159",
"name": "Database", "name": "Database",
"description": "MySQL related problems" "description": "MySQL related problems"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14314", "self": "https://my.jira.com/rest/api/2/component/14314",
"id": "14314", "id": "14314",
"name": "Documentation" "name": "Documentation"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14151", "self": "https://my.jira.com/rest/api/2/component/14151",
"id": "14151", "id": "14151",
"name": "Git", "name": "Git",
"description": "Bitbucket, GitHub, GitLab, Git in general" "description": "Bitbucket, GitHub, GitLab, Git in general"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14155", "self": "https://my.jira.com/rest/api/2/component/14155",
"id": "14155", "id": "14155",
"name": "HTTP services", "name": "HTTP services",
"description": "CDN, HaProxy, HTTP, Varnish" "description": "CDN, HaProxy, HTTP, Varnish"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14154", "self": "https://my.jira.com/rest/api/2/component/14154",
"id": "14154", "id": "14154",
"name": "Job and service scheduling", "name": "Job and service scheduling",
"description": "Chronos, Docker, Marathon, Mesos" "description": "Chronos, Docker, Marathon, Mesos"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14158", "self": "https://my.jira.com/rest/api/2/component/14158",
"id": "14158", "id": "14158",
"name": "Legacy", "name": "Legacy",
"description": "Everything related to legacy" "description": "Everything related to legacy"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14157", "self": "https://my.jira.com/rest/api/2/component/14157",
"id": "14157", "id": "14157",
"name": "Monitoring", "name": "Monitoring",
"description": "Collectd, Nagios, Monitoring in general" "description": "Collectd, Nagios, Monitoring in general"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14148", "self": "https://my.jira.com/rest/api/2/component/14148",
"id": "14148", "id": "14148",
"name": "Other services" "name": "Other services"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/13602", "self": "https://my.jira.com/rest/api/2/component/13602",
"id": "13602", "id": "13602",
"name": "Package management", "name": "Package management",
"description": "Composer, Medusa, Satis" "description": "Composer, Medusa, Satis"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14145", "self": "https://my.jira.com/rest/api/2/component/14145",
"id": "14145", "id": "14145",
"name": "Release", "name": "Release",
"description": "Directory config, release queries, rewrite rules" "description": "Directory config, release queries, rewrite rules"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14146", "self": "https://my.jira.com/rest/api/2/component/14146",
"id": "14146", "id": "14146",
"name": "Staging systems and VMs", "name": "Staging systems and VMs",
"description": "Stage, QA machines, KVMs,Vagrant" "description": "Stage, QA machines, KVMs,Vagrant"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14153", "self": "https://my.jira.com/rest/api/2/component/14153",
"id": "14153", "id": "14153",
"name": "Techblog" "name": "Blog"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14143", "self": "https://my.jira.com/rest/api/2/component/14143",
"id": "14143", "id": "14143",
"name": "Test automation", "name": "Test automation",
"description": "Testing infrastructure in general" "description": "Testing infrastructure in general"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/component/14221", "self": "https://my.jira.com/rest/api/2/component/14221",
"id": "14221", "id": "14221",
"name": "Zup" "name": "Internal Infrastructure"
}] }]
}, },
"attachment": { "attachment": {
@ -251,18 +251,18 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
"set" "set"
], ],
"allowedValues": [{ "allowedValues": [{
"self": "https://tasks.trivago.com/rest/api/2/project/11300", "self": "https://my.jira.com/rest/api/2/project/11300",
"id": "11300", "id": "11300",
"key": "SOP", "key": "SPN",
"name": "DSE - Software Operations", "name": "Super Project Name",
"avatarUrls": { "avatarUrls": {
"48x48": "https://tasks.trivago.com/secure/projectavatar?pid=11300&avatarId=14405", "48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
"24x24": "https://tasks.trivago.com/secure/projectavatar?size=small&pid=11300&avatarId=14405", "24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
"16x16": "https://tasks.trivago.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405", "16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
"32x32": "https://tasks.trivago.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405" "32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
}, },
"projectCategory": { "projectCategory": {
"self": "https://tasks.trivago.com/rest/api/2/projectCategory/10100", "self": "https://my.jira.com/rest/api/2/projectCategory/10100",
"id": "10100", "id": "10100",
"description": "", "description": "",
"name": "Product & Development" "name": "Product & Development"
@ -276,7 +276,7 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
"system": "assignee" "system": "assignee"
}, },
"name": "Assignee", "name": "Assignee",
"autoCompleteUrl": "https://tasks.trivago.com/rest/api/latest/user/assignable/search?issueKey=null&username=", "autoCompleteUrl": "https://my.jira.com/rest/api/latest/user/assignable/search?issueKey=null&username=",
"hasDefaultValue": true, "hasDefaultValue": true,
"operations": [ "operations": [
"set" "set"
@ -294,33 +294,33 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
"set" "set"
], ],
"allowedValues": [{ "allowedValues": [{
"self": "https://tasks.trivago.com/rest/api/2/priority/1", "self": "https://my.jira.com/rest/api/2/priority/1",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/blocker.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/blocker.svg",
"name": "Immediate", "name": "Immediate",
"id": "1" "id": "1"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/priority/2", "self": "https://my.jira.com/rest/api/2/priority/2",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/critical.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/critical.svg",
"name": "Urgent", "name": "Urgent",
"id": "2" "id": "2"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/priority/3", "self": "https://my.jira.com/rest/api/2/priority/3",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/major.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/major.svg",
"name": "High", "name": "High",
"id": "3" "id": "3"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/priority/6", "self": "https://my.jira.com/rest/api/2/priority/6",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/moderate.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/moderate.svg",
"name": "Moderate", "name": "Moderate",
"id": "6" "id": "6"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/priority/4", "self": "https://my.jira.com/rest/api/2/priority/4",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/minor.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/minor.svg",
"name": "Normal", "name": "Normal",
"id": "4" "id": "4"
}, { }, {
"self": "https://tasks.trivago.com/rest/api/2/priority/5", "self": "https://my.jira.com/rest/api/2/priority/5",
"iconUrl": "https://tasks.trivago.com/images/icons/priorities/trivial.svg", "iconUrl": "https://my.jira.com/images/icons/priorities/trivial.svg",
"name": "Low", "name": "Low",
"id": "5" "id": "5"
}] }]
@ -333,7 +333,7 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
"system": "labels" "system": "labels"
}, },
"name": "Labels", "name": "Labels",
"autoCompleteUrl": "https://tasks.trivago.com/rest/api/1.0/labels/suggest?query=", "autoCompleteUrl": "https://my.jira.com/rest/api/1.0/labels/suggest?query=",
"hasDefaultValue": false, "hasDefaultValue": false,
"operations": [ "operations": [
"add", "add",
@ -347,7 +347,7 @@ func TestIssueService_GetCreateMeta_Success(t *testing.T) {
}`) }`)
}) })
issue, _, err := testClient.Issue.GetCreateMeta("SOP") issue, _, err := testClient.Issue.GetCreateMeta("SPN")
if err != nil { if err != nil {
t.Errorf("Expected nil error but got %s", err) t.Errorf("Expected nil error but got %s", err)
} }
@ -405,9 +405,8 @@ func TestMetaIssueTypes_GetMandatoryFields(t *testing.T) {
} }
if len(mandatory) != 2 { if len(mandatory) != 2 {
t.Errorf("Expected 2 recieved %d", mandatory) t.Errorf("Expected 2 recieved %+v", mandatory)
} }
} }
func TestMetaIssueTypes_GetMandatoryFields_NonExistentRequiredKey_Fail(t *testing.T) { func TestMetaIssueTypes_GetMandatoryFields_NonExistentRequiredKey_Fail(t *testing.T) {
@ -424,7 +423,6 @@ func TestMetaIssueTypes_GetMandatoryFields_NonExistentRequiredKey_Fail(t *testin
if err == nil { if err == nil {
t.Error("Expected non nil errpr, recieved nil") t.Error("Expected non nil errpr, recieved nil")
} }
} }
func TestMetaIssueTypes_GetMandatoryFields_NonExistentNameKey_Fail(t *testing.T) { func TestMetaIssueTypes_GetMandatoryFields_NonExistentNameKey_Fail(t *testing.T) {
@ -441,7 +439,6 @@ func TestMetaIssueTypes_GetMandatoryFields_NonExistentNameKey_Fail(t *testing.T)
if err == nil { if err == nil {
t.Error("Expected non nil errpr, recieved nil") t.Error("Expected non nil errpr, recieved nil")
} }
} }
func TestMetaIssueTypes_GetAllFields(t *testing.T) { func TestMetaIssueTypes_GetAllFields(t *testing.T) {
@ -472,9 +469,8 @@ func TestMetaIssueTypes_GetAllFields(t *testing.T) {
} }
if len(mandatory) != 3 { if len(mandatory) != 3 {
t.Errorf("Expected 3 recieved %d", mandatory) t.Errorf("Expected 3 recieved %+v", mandatory)
} }
} }
func TestMetaIssueTypes_GetAllFields_NonExistingNameKey_Fail(t *testing.T) { func TestMetaIssueTypes_GetAllFields_NonExistingNameKey_Fail(t *testing.T) {
@ -491,21 +487,18 @@ func TestMetaIssueTypes_GetAllFields_NonExistingNameKey_Fail(t *testing.T) {
if err == nil { if err == nil {
t.Error("Expected non nil error, recieved nil") t.Error("Expected non nil error, recieved nil")
} }
} }
func TestCreateMetaInfo_GetProjectName_Success(t *testing.T) { func TestCreateMetaInfo_GetProjectName_Success(t *testing.T) {
metainfo := new(CreateMetaInfo) metainfo := new(CreateMetaInfo)
metainfo.Projects = append(metainfo.Projects, &MetaProject{ metainfo.Projects = append(metainfo.Projects, &MetaProject{
Name: "SOP", Name: "SPN",
}) })
project := metainfo.GetProjectWithName("SOP") project := metainfo.GetProjectWithName("SPN")
if project == nil { if project == nil {
t.Errorf("Expected non nil value, recieved nil") t.Errorf("Expected non nil value, recieved nil")
return
} }
} }
func TestMetaProject_GetIssueTypeWithName_CaseMismatch_Success(t *testing.T) { func TestMetaProject_GetIssueTypeWithName_CaseMismatch_Success(t *testing.T) {
@ -518,6 +511,5 @@ func TestMetaProject_GetIssueTypeWithName_CaseMismatch_Success(t *testing.T) {
if issuetype == nil { if issuetype == nil {
t.Errorf("Expected non nil value, recieved nil") t.Errorf("Expected non nil value, recieved nil")
return
} }
} }