2016-09-20 14:27:54 +02:00
|
|
|
package jira
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIssueService_GetCreateMeta_Success(t *testing.T) {
|
|
|
|
setup()
|
|
|
|
defer teardown()
|
|
|
|
|
2016-10-03 13:33:46 +02:00
|
|
|
testAPIEndpoint := "/rest/api/2/issue/createmeta"
|
2016-09-20 14:27:54 +02:00
|
|
|
|
2016-10-03 13:33:46 +02:00
|
|
|
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
|
2016-09-20 14:27:54 +02:00
|
|
|
testMethod(t, r, "GET")
|
2016-10-03 13:33:46 +02:00
|
|
|
testRequestURL(t, r, testAPIEndpoint)
|
2016-09-20 14:27:54 +02:00
|
|
|
|
|
|
|
fmt.Fprint(w, `{
|
|
|
|
"expand": "projects",
|
|
|
|
"projects": [{
|
|
|
|
"expand": "issuetypes",
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/project/11300",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "11300",
|
2016-10-03 13:33:46 +02:00
|
|
|
"key": "SPN",
|
|
|
|
"name": "Super Project Name",
|
2016-09-20 14:27:54 +02:00
|
|
|
"avatarUrls": {
|
2016-10-03 13:33:46 +02:00
|
|
|
"48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
|
|
|
|
"24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
|
|
|
|
"16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
|
|
|
|
"32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
|
2016-09-20 14:27:54 +02:00
|
|
|
},
|
|
|
|
"issuetypes": [{
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/issuetype/6",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "6",
|
|
|
|
"description": "An issue which ideally should be able to be completed in one step",
|
2016-10-03 13:33:46 +02:00
|
|
|
"iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Request",
|
|
|
|
"subtask": false,
|
|
|
|
"expand": "fields",
|
|
|
|
"fields": {
|
|
|
|
"summary": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "string",
|
|
|
|
"system": "summary"
|
|
|
|
},
|
|
|
|
"name": "Summary",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"issuetype": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "issuetype",
|
|
|
|
"system": "issuetype"
|
|
|
|
},
|
|
|
|
"name": "Issue Type",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/issuetype/6",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "6",
|
|
|
|
"description": "An issue which ideally should be able to be completed in one step",
|
2016-10-03 13:33:46 +02:00
|
|
|
"iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Request",
|
|
|
|
"subtask": false,
|
|
|
|
"avatarId": 14006
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"components": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "component",
|
|
|
|
"system": "components"
|
|
|
|
},
|
|
|
|
"name": "Component/s",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"add",
|
|
|
|
"set",
|
|
|
|
"remove"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14144",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14144",
|
|
|
|
"name": "Build automation",
|
|
|
|
"description": "Jenkins, webhooks, etc."
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14149",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14149",
|
|
|
|
"name": "Caches and noSQL",
|
|
|
|
"description": "Cassandra, Memcached, Redis, Twemproxy, Xcache"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14152",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14152",
|
|
|
|
"name": "Cloud services",
|
2017-05-01 15:03:03 +02:00
|
|
|
"description": "AWS and similar services"
|
2016-09-20 14:27:54 +02:00
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14147",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14147",
|
|
|
|
"name": "Code quality tools",
|
2016-10-03 13:33:46 +02:00
|
|
|
"description": "Code sniffer, Sonar"
|
2016-09-20 14:27:54 +02:00
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14156",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14156",
|
|
|
|
"name": "Configuration management and provisioning",
|
|
|
|
"description": "Apache/PHP modules, Consul, Salt"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/13606",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "13606",
|
|
|
|
"name": "Cronjobs",
|
|
|
|
"description": "Cronjobs in general"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14150",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14150",
|
|
|
|
"name": "Data pipelines and queues",
|
2016-10-03 13:33:46 +02:00
|
|
|
"description": "Kafka, RabbitMq"
|
2016-09-20 14:27:54 +02:00
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14159",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14159",
|
|
|
|
"name": "Database",
|
|
|
|
"description": "MySQL related problems"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14314",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14314",
|
|
|
|
"name": "Documentation"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14151",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14151",
|
|
|
|
"name": "Git",
|
|
|
|
"description": "Bitbucket, GitHub, GitLab, Git in general"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14155",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14155",
|
|
|
|
"name": "HTTP services",
|
|
|
|
"description": "CDN, HaProxy, HTTP, Varnish"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14154",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14154",
|
|
|
|
"name": "Job and service scheduling",
|
|
|
|
"description": "Chronos, Docker, Marathon, Mesos"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14158",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14158",
|
|
|
|
"name": "Legacy",
|
|
|
|
"description": "Everything related to legacy"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14157",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14157",
|
|
|
|
"name": "Monitoring",
|
|
|
|
"description": "Collectd, Nagios, Monitoring in general"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14148",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14148",
|
|
|
|
"name": "Other services"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/13602",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "13602",
|
|
|
|
"name": "Package management",
|
|
|
|
"description": "Composer, Medusa, Satis"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14145",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14145",
|
|
|
|
"name": "Release",
|
|
|
|
"description": "Directory config, release queries, rewrite rules"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14146",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14146",
|
|
|
|
"name": "Staging systems and VMs",
|
|
|
|
"description": "Stage, QA machines, KVMs,Vagrant"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14153",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14153",
|
2016-10-03 13:33:46 +02:00
|
|
|
"name": "Blog"
|
2016-09-20 14:27:54 +02:00
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14143",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14143",
|
|
|
|
"name": "Test automation",
|
|
|
|
"description": "Testing infrastructure in general"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14221",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "14221",
|
2016-10-03 13:33:46 +02:00
|
|
|
"name": "Internal Infrastructure"
|
2016-09-20 14:27:54 +02:00
|
|
|
}]
|
|
|
|
},
|
|
|
|
"attachment": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "attachment",
|
|
|
|
"system": "attachment"
|
|
|
|
},
|
|
|
|
"name": "Attachment",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"duedate": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "date",
|
|
|
|
"system": "duedate"
|
|
|
|
},
|
|
|
|
"name": "Due Date",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"description": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "string",
|
|
|
|
"system": "description"
|
|
|
|
},
|
|
|
|
"name": "Description",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"customfield_10806": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "any",
|
|
|
|
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
|
|
|
|
"customId": 10806
|
|
|
|
},
|
|
|
|
"name": "Epic Link",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"project": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "project",
|
|
|
|
"system": "project"
|
|
|
|
},
|
|
|
|
"name": "Project",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/project/11300",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "11300",
|
2016-10-03 13:33:46 +02:00
|
|
|
"key": "SPN",
|
|
|
|
"name": "Super Project Name",
|
2016-09-20 14:27:54 +02:00
|
|
|
"avatarUrls": {
|
2016-10-03 13:33:46 +02:00
|
|
|
"48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
|
|
|
|
"24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
|
|
|
|
"16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
|
|
|
|
"32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
|
2016-09-20 14:27:54 +02:00
|
|
|
},
|
|
|
|
"projectCategory": {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/projectCategory/10100",
|
2016-09-20 14:27:54 +02:00
|
|
|
"id": "10100",
|
|
|
|
"description": "",
|
|
|
|
"name": "Product & Development"
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"assignee": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "user",
|
|
|
|
"system": "assignee"
|
|
|
|
},
|
|
|
|
"name": "Assignee",
|
2016-10-03 13:33:46 +02:00
|
|
|
"autoCompleteUrl": "https://my.jira.com/rest/api/latest/user/assignable/search?issueKey=null&username=",
|
2016-09-20 14:27:54 +02:00
|
|
|
"hasDefaultValue": true,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"priority": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "priority",
|
|
|
|
"system": "priority"
|
|
|
|
},
|
|
|
|
"name": "Priority",
|
|
|
|
"hasDefaultValue": true,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/1",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/blocker.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Immediate",
|
|
|
|
"id": "1"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/2",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/critical.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Urgent",
|
|
|
|
"id": "2"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/3",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/major.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "High",
|
|
|
|
"id": "3"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/6",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/moderate.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Moderate",
|
|
|
|
"id": "6"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/4",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/minor.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Normal",
|
|
|
|
"id": "4"
|
|
|
|
}, {
|
2016-10-03 13:33:46 +02:00
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/5",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/trivial.svg",
|
2016-09-20 14:27:54 +02:00
|
|
|
"name": "Low",
|
|
|
|
"id": "5"
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"labels": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "string",
|
|
|
|
"system": "labels"
|
|
|
|
},
|
|
|
|
"name": "Labels",
|
2016-10-03 13:33:46 +02:00
|
|
|
"autoCompleteUrl": "https://my.jira.com/rest/api/1.0/labels/suggest?query=",
|
2016-09-20 14:27:54 +02:00
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"add",
|
|
|
|
"set",
|
|
|
|
"remove"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}`)
|
|
|
|
})
|
|
|
|
|
2016-10-03 13:33:46 +02:00
|
|
|
issue, _, err := testClient.Issue.GetCreateMeta("SPN")
|
2016-09-20 14:27:54 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Expected nil error but got %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(issue.Projects) != 1 {
|
|
|
|
t.Errorf("Expected 1 project, got %d", len(issue.Projects))
|
|
|
|
}
|
|
|
|
for _, project := range issue.Projects {
|
|
|
|
if len(project.IssueTypes) != 1 {
|
|
|
|
t.Errorf("Expected 1 issueTypes, got %d", len(project.IssueTypes))
|
|
|
|
}
|
|
|
|
for _, issueTypes := range project.IssueTypes {
|
|
|
|
requiredFields := 0
|
|
|
|
fields := issueTypes.Fields
|
|
|
|
for _, value := range fields {
|
|
|
|
for key, value := range value.(map[string]interface{}) {
|
|
|
|
if key == "required" && value == true {
|
|
|
|
requiredFields = requiredFields + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if requiredFields != 5 {
|
|
|
|
t.Errorf("Expected 5 required fields from Create Meta information, got %d", requiredFields)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2016-09-23 16:19:07 +02:00
|
|
|
|
2018-03-01 17:46:22 +02:00
|
|
|
func TestMetaIssueType_GetCreateMetaWithOptions(t *testing.T) {
|
|
|
|
setup()
|
|
|
|
defer teardown()
|
|
|
|
|
|
|
|
testAPIEndpoint := "/rest/api/2/issue/createmeta"
|
|
|
|
|
|
|
|
testMux.HandleFunc(testAPIEndpoint, func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
testMethod(t, r, "GET")
|
|
|
|
testRequestURL(t, r, testAPIEndpoint)
|
|
|
|
|
|
|
|
fmt.Fprint(w, `{
|
|
|
|
"expand": "projects",
|
|
|
|
"projects": [{
|
|
|
|
"expand": "issuetypes",
|
|
|
|
"self": "https://my.jira.com/rest/api/2/project/11300",
|
|
|
|
"id": "11300",
|
|
|
|
"key": "SPN",
|
|
|
|
"name": "Super Project Name",
|
|
|
|
"avatarUrls": {
|
|
|
|
"48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
|
|
|
|
"24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
|
|
|
|
"16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
|
|
|
|
"32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
|
|
|
|
},
|
|
|
|
"issuetypes": [{
|
|
|
|
"self": "https://my.jira.com/rest/api/2/issuetype/6",
|
|
|
|
"id": "6",
|
|
|
|
"description": "An issue which ideally should be able to be completed in one step",
|
|
|
|
"iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
|
|
|
|
"name": "Request",
|
|
|
|
"subtask": false,
|
|
|
|
"expand": "fields",
|
|
|
|
"fields": {
|
|
|
|
"summary": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "string",
|
|
|
|
"system": "summary"
|
|
|
|
},
|
|
|
|
"name": "Summary",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"issuetype": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "issuetype",
|
|
|
|
"system": "issuetype"
|
|
|
|
},
|
|
|
|
"name": "Issue Type",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
|
|
|
"self": "https://my.jira.com/rest/api/2/issuetype/6",
|
|
|
|
"id": "6",
|
|
|
|
"description": "An issue which ideally should be able to be completed in one step",
|
|
|
|
"iconUrl": "https://my.jira.com/secure/viewavatar?size=xsmall&avatarId=14006&avatarType=issuetype",
|
|
|
|
"name": "Request",
|
|
|
|
"subtask": false,
|
|
|
|
"avatarId": 14006
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"components": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "component",
|
|
|
|
"system": "components"
|
|
|
|
},
|
|
|
|
"name": "Component/s",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"add",
|
|
|
|
"set",
|
|
|
|
"remove"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14144",
|
|
|
|
"id": "14144",
|
|
|
|
"name": "Build automation",
|
|
|
|
"description": "Jenkins, webhooks, etc."
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14149",
|
|
|
|
"id": "14149",
|
|
|
|
"name": "Caches and noSQL",
|
|
|
|
"description": "Cassandra, Memcached, Redis, Twemproxy, Xcache"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14152",
|
|
|
|
"id": "14152",
|
|
|
|
"name": "Cloud services",
|
|
|
|
"description": "AWS and similar services"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14147",
|
|
|
|
"id": "14147",
|
|
|
|
"name": "Code quality tools",
|
|
|
|
"description": "Code sniffer, Sonar"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14156",
|
|
|
|
"id": "14156",
|
|
|
|
"name": "Configuration management and provisioning",
|
|
|
|
"description": "Apache/PHP modules, Consul, Salt"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/13606",
|
|
|
|
"id": "13606",
|
|
|
|
"name": "Cronjobs",
|
|
|
|
"description": "Cronjobs in general"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14150",
|
|
|
|
"id": "14150",
|
|
|
|
"name": "Data pipelines and queues",
|
|
|
|
"description": "Kafka, RabbitMq"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14159",
|
|
|
|
"id": "14159",
|
|
|
|
"name": "Database",
|
|
|
|
"description": "MySQL related problems"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14314",
|
|
|
|
"id": "14314",
|
|
|
|
"name": "Documentation"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14151",
|
|
|
|
"id": "14151",
|
|
|
|
"name": "Git",
|
|
|
|
"description": "Bitbucket, GitHub, GitLab, Git in general"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14155",
|
|
|
|
"id": "14155",
|
|
|
|
"name": "HTTP services",
|
|
|
|
"description": "CDN, HaProxy, HTTP, Varnish"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14154",
|
|
|
|
"id": "14154",
|
|
|
|
"name": "Job and service scheduling",
|
|
|
|
"description": "Chronos, Docker, Marathon, Mesos"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14158",
|
|
|
|
"id": "14158",
|
|
|
|
"name": "Legacy",
|
|
|
|
"description": "Everything related to legacy"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14157",
|
|
|
|
"id": "14157",
|
|
|
|
"name": "Monitoring",
|
|
|
|
"description": "Collectd, Nagios, Monitoring in general"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14148",
|
|
|
|
"id": "14148",
|
|
|
|
"name": "Other services"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/13602",
|
|
|
|
"id": "13602",
|
|
|
|
"name": "Package management",
|
|
|
|
"description": "Composer, Medusa, Satis"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14145",
|
|
|
|
"id": "14145",
|
|
|
|
"name": "Release",
|
|
|
|
"description": "Directory config, release queries, rewrite rules"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14146",
|
|
|
|
"id": "14146",
|
|
|
|
"name": "Staging systems and VMs",
|
|
|
|
"description": "Stage, QA machines, KVMs,Vagrant"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14153",
|
|
|
|
"id": "14153",
|
|
|
|
"name": "Blog"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14143",
|
|
|
|
"id": "14143",
|
|
|
|
"name": "Test automation",
|
|
|
|
"description": "Testing infrastructure in general"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/component/14221",
|
|
|
|
"id": "14221",
|
|
|
|
"name": "Internal Infrastructure"
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"attachment": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "attachment",
|
|
|
|
"system": "attachment"
|
|
|
|
},
|
|
|
|
"name": "Attachment",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"duedate": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "date",
|
|
|
|
"system": "duedate"
|
|
|
|
},
|
|
|
|
"name": "Due Date",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"description": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "string",
|
|
|
|
"system": "description"
|
|
|
|
},
|
|
|
|
"name": "Description",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"customfield_10806": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "any",
|
|
|
|
"custom": "com.pyxis.greenhopper.jira:gh-epic-link",
|
|
|
|
"customId": 10806
|
|
|
|
},
|
|
|
|
"name": "Epic Link",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"project": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "project",
|
|
|
|
"system": "project"
|
|
|
|
},
|
|
|
|
"name": "Project",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
|
|
|
"self": "https://my.jira.com/rest/api/2/project/11300",
|
|
|
|
"id": "11300",
|
|
|
|
"key": "SPN",
|
|
|
|
"name": "Super Project Name",
|
|
|
|
"avatarUrls": {
|
|
|
|
"48x48": "https://my.jira.com/secure/projectavatar?pid=11300&avatarId=14405",
|
|
|
|
"24x24": "https://my.jira.com/secure/projectavatar?size=small&pid=11300&avatarId=14405",
|
|
|
|
"16x16": "https://my.jira.com/secure/projectavatar?size=xsmall&pid=11300&avatarId=14405",
|
|
|
|
"32x32": "https://my.jira.com/secure/projectavatar?size=medium&pid=11300&avatarId=14405"
|
|
|
|
},
|
|
|
|
"projectCategory": {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/projectCategory/10100",
|
|
|
|
"id": "10100",
|
|
|
|
"description": "",
|
|
|
|
"name": "Product & Development"
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"assignee": {
|
|
|
|
"required": true,
|
|
|
|
"schema": {
|
|
|
|
"type": "user",
|
|
|
|
"system": "assignee"
|
|
|
|
},
|
|
|
|
"name": "Assignee",
|
|
|
|
"autoCompleteUrl": "https://my.jira.com/rest/api/latest/user/assignable/search?issueKey=null&username=",
|
|
|
|
"hasDefaultValue": true,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"priority": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "priority",
|
|
|
|
"system": "priority"
|
|
|
|
},
|
|
|
|
"name": "Priority",
|
|
|
|
"hasDefaultValue": true,
|
|
|
|
"operations": [
|
|
|
|
"set"
|
|
|
|
],
|
|
|
|
"allowedValues": [{
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/1",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/blocker.svg",
|
|
|
|
"name": "Immediate",
|
|
|
|
"id": "1"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/2",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/critical.svg",
|
|
|
|
"name": "Urgent",
|
|
|
|
"id": "2"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/3",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/major.svg",
|
|
|
|
"name": "High",
|
|
|
|
"id": "3"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/6",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/moderate.svg",
|
|
|
|
"name": "Moderate",
|
|
|
|
"id": "6"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/4",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/minor.svg",
|
|
|
|
"name": "Normal",
|
|
|
|
"id": "4"
|
|
|
|
}, {
|
|
|
|
"self": "https://my.jira.com/rest/api/2/priority/5",
|
|
|
|
"iconUrl": "https://my.jira.com/images/icons/priorities/trivial.svg",
|
|
|
|
"name": "Low",
|
|
|
|
"id": "5"
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
"labels": {
|
|
|
|
"required": false,
|
|
|
|
"schema": {
|
|
|
|
"type": "array",
|
|
|
|
"items": "string",
|
|
|
|
"system": "labels"
|
|
|
|
},
|
|
|
|
"name": "Labels",
|
|
|
|
"autoCompleteUrl": "https://my.jira.com/rest/api/1.0/labels/suggest?query=",
|
|
|
|
"hasDefaultValue": false,
|
|
|
|
"operations": [
|
|
|
|
"add",
|
|
|
|
"set",
|
|
|
|
"remove"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}]
|
|
|
|
}`)
|
|
|
|
})
|
|
|
|
|
|
|
|
issue, _, err := testClient.Issue.GetCreateMetaWithOptions(&GetQueryOptions{Expand: "projects.issuetypes.fields"})
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Expected nil error but got %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(issue.Projects) != 1 {
|
|
|
|
t.Errorf("Expected 1 project, got %d", len(issue.Projects))
|
|
|
|
}
|
|
|
|
for _, project := range issue.Projects {
|
|
|
|
if len(project.IssueTypes) != 1 {
|
|
|
|
t.Errorf("Expected 1 issueTypes, got %d", len(project.IssueTypes))
|
|
|
|
}
|
|
|
|
for _, issueTypes := range project.IssueTypes {
|
|
|
|
requiredFields := 0
|
|
|
|
fields := issueTypes.Fields
|
|
|
|
for _, value := range fields {
|
|
|
|
for key, value := range value.(map[string]interface{}) {
|
|
|
|
if key == "required" && value == true {
|
|
|
|
requiredFields = requiredFields + 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if requiredFields != 5 {
|
|
|
|
t.Errorf("Expected 5 required fields from Create Meta information, got %d", requiredFields)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestMetaIssueType_GetMandatoryFields(t *testing.T) {
|
2016-09-23 16:19:07 +02:00
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["components"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Components",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["epicLink"] = map[string]interface{}{
|
|
|
|
"required": false,
|
|
|
|
"name": "Epic Link",
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
m := new(MetaIssueType)
|
2016-09-23 16:19:07 +02:00
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
mandatory, err := m.GetMandatoryFields()
|
|
|
|
if err != nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected nil error, received %s", err)
|
2016-09-23 16:19:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(mandatory) != 2 {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected 2 received %+v", mandatory)
|
2016-09-23 16:19:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestMetaIssueType_GetMandatoryFields_NonExistentRequiredKey_Fail(t *testing.T) {
|
2016-09-27 13:26:07 +02:00
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
m := new(MetaIssueType)
|
2016-09-27 13:26:07 +02:00
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
_, err := m.GetMandatoryFields()
|
|
|
|
if err == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Error("Expected non nil errpr, received nil")
|
2016-09-27 13:26:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestMetaIssueType_GetMandatoryFields_NonExistentNameKey_Fail(t *testing.T) {
|
2016-09-27 13:26:07 +02:00
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
m := new(MetaIssueType)
|
2016-09-27 13:26:07 +02:00
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
_, err := m.GetMandatoryFields()
|
|
|
|
if err == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Error("Expected non nil errpr, received nil")
|
2016-09-27 13:26:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestMetaIssueType_GetAllFields(t *testing.T) {
|
2016-09-23 16:19:07 +02:00
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["components"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Components",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["epicLink"] = map[string]interface{}{
|
|
|
|
"required": false,
|
|
|
|
"name": "Epic Link",
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
m := new(MetaIssueType)
|
2016-09-23 16:19:07 +02:00
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
mandatory, err := m.GetAllFields()
|
|
|
|
|
|
|
|
if err != nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected nil err, received %s", err)
|
2016-09-23 16:19:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(mandatory) != 3 {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected 3 received %+v", mandatory)
|
2016-09-23 16:19:07 +02:00
|
|
|
}
|
|
|
|
}
|
2016-09-27 11:54:09 +02:00
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestMetaIssueType_GetAllFields_NonExistingNameKey_Fail(t *testing.T) {
|
2016-09-27 13:26:07 +02:00
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
m := new(MetaIssueType)
|
2016-09-27 13:26:07 +02:00
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
_, err := m.GetAllFields()
|
|
|
|
if err == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Error("Expected non nil error, received nil")
|
2016-09-27 13:26:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-05 18:29:09 +02:00
|
|
|
func TestMetaIssueType_CheckCompleteAndAvailable_MandatoryMissing(t *testing.T) {
|
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["someKey"] = map[string]interface{}{
|
|
|
|
"required": false,
|
|
|
|
"name": "SomeKey",
|
|
|
|
}
|
|
|
|
|
|
|
|
config := map[string]string{
|
|
|
|
"SomeKey": "somevalue",
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(MetaIssueType)
|
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
ok, err := m.CheckCompleteAndAvailable(config)
|
|
|
|
if err == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Error("Expected non nil error. Received nil")
|
2016-10-05 18:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ok != false {
|
|
|
|
t.Error("Expected false, got true")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaIssueType_CheckCompleteAndAvailable_NotAvailable(t *testing.T) {
|
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
config := map[string]string{
|
2016-10-05 18:42:31 +02:00
|
|
|
"Summary": "Issue Summary",
|
2016-10-05 18:29:09 +02:00
|
|
|
"SomeKey": "somevalue",
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(MetaIssueType)
|
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
ok, err := m.CheckCompleteAndAvailable(config)
|
|
|
|
if err == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Error("Expected non nil error. Received nil")
|
2016-10-05 18:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ok != false {
|
|
|
|
t.Error("Expected false, got true")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaIssueType_CheckCompleteAndAvailable_Success(t *testing.T) {
|
|
|
|
data := make(map[string]interface{})
|
|
|
|
|
|
|
|
data["summary"] = map[string]interface{}{
|
|
|
|
"required": true,
|
|
|
|
"name": "Summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
data["someKey"] = map[string]interface{}{
|
|
|
|
"required": false,
|
|
|
|
"name": "SomeKey",
|
|
|
|
}
|
|
|
|
|
|
|
|
config := map[string]string{
|
|
|
|
"SomeKey": "somevalue",
|
|
|
|
"Summary": "Issue summary",
|
|
|
|
}
|
|
|
|
|
|
|
|
m := new(MetaIssueType)
|
|
|
|
m.Fields = data
|
|
|
|
|
|
|
|
ok, err := m.CheckCompleteAndAvailable(config)
|
|
|
|
if err != nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected nil error. Received %s", err)
|
2016-10-05 18:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ok != true {
|
|
|
|
t.Error("Expected true, got false")
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-05 10:55:52 +02:00
|
|
|
func TestCreateMetaInfo_GetProjectWithName_Success(t *testing.T) {
|
2016-09-27 11:54:09 +02:00
|
|
|
metainfo := new(CreateMetaInfo)
|
|
|
|
metainfo.Projects = append(metainfo.Projects, &MetaProject{
|
2016-10-03 13:33:46 +02:00
|
|
|
Name: "SPN",
|
2016-09-27 11:54:09 +02:00
|
|
|
})
|
|
|
|
|
2016-10-03 13:33:46 +02:00
|
|
|
project := metainfo.GetProjectWithName("SPN")
|
2016-09-27 11:54:09 +02:00
|
|
|
if project == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected non nil value, received nil")
|
2016-09-27 11:54:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaProject_GetIssueTypeWithName_CaseMismatch_Success(t *testing.T) {
|
|
|
|
m := new(MetaProject)
|
2016-10-05 10:55:52 +02:00
|
|
|
m.IssueTypes = append(m.IssueTypes, &MetaIssueType{
|
2016-09-27 11:54:09 +02:00
|
|
|
Name: "Bug",
|
|
|
|
})
|
|
|
|
|
|
|
|
issuetype := m.GetIssueTypeWithName("BUG")
|
|
|
|
|
|
|
|
if issuetype == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected non nil value, received nil")
|
2016-09-27 11:54:09 +02:00
|
|
|
}
|
|
|
|
}
|
2016-10-05 10:55:52 +02:00
|
|
|
|
|
|
|
func TestCreateMetaInfo_GetProjectWithKey_Success(t *testing.T) {
|
|
|
|
metainfo := new(CreateMetaInfo)
|
|
|
|
metainfo.Projects = append(metainfo.Projects, &MetaProject{
|
|
|
|
Key: "SPNKEY",
|
|
|
|
})
|
|
|
|
|
|
|
|
project := metainfo.GetProjectWithKey("SPNKEY")
|
|
|
|
if project == nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected non nil value, received nil")
|
2016-10-05 10:55:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCreateMetaInfo_GetProjectWithKey_NilForNonExistent(t *testing.T) {
|
|
|
|
metainfo := new(CreateMetaInfo)
|
|
|
|
metainfo.Projects = append(metainfo.Projects, &MetaProject{
|
|
|
|
Key: "SPNKEY",
|
|
|
|
})
|
|
|
|
|
|
|
|
project := metainfo.GetProjectWithKey("SPN")
|
|
|
|
if project != nil {
|
2017-05-01 14:59:27 +02:00
|
|
|
t.Errorf("Expected nil, received value")
|
2016-10-05 10:55:52 +02:00
|
|
|
}
|
|
|
|
}
|