-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
92 lines (73 loc) · 2.08 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package main_test
import (
"github.com/vsaveliev/jira-to-slack"
"github.com/vsaveliev/jira-to-slack/jira"
"testing"
)
func TestCreatedIssueEvent(t *testing.T) {
jiraObject := getJiraObject()
event := getEventCreatedIssue()
jiraObject.Process(event)
}
func TestUpdatedIssueEvent(t *testing.T) {
jiraObject := getJiraObject()
event := getEventUpdatedIssue()
jiraObject.Process(event)
}
func TestResolvedIssueEvent(t *testing.T) {
jiraObject := getJiraObject()
event := getEventResolvedIssue()
jiraObject.Process(event)
}
func getJiraObject() jira.Jira {
config := main.GetConfig()
jiraObject := jira.Jira{}
jiraObject.Config = config.JiraConfig
return jiraObject
}
func getEventCreatedIssue() jira.WebHookEvent {
event := jira.WebHookEvent{}
event.Event = "jira:issue_created"
event.Issue.Fields.Assignee.DisplayName = "Jonh White"
event.Issue.Fields.Creator.DisplayName = "Michael Daddy"
event.Issue.Fields.Reporter.DisplayName = "Michael Daddy"
event.Modifier.DisplayName = "John Jones"
event.Issue.Fields.IssueType.Name = "Bug"
event.Issue.Fields.Status.Name = "Open"
event.Issue.Fields.Summary = "Some summary of bug"
event.Issue.Key = "OP-1111"
return event
}
func getEventUpdatedIssue() jira.WebHookEvent {
event := getEventCreatedIssue()
event.Modifier.DisplayName = "Jonh White"
event.Event = "jira:issue_updated"
items := make([]jira.ChangeLogItem, 2);
items[0] = jira.ChangeLogItem{
Field: "status",
FromString: "Open",
ToString: "In progress",
}
items[1] = jira.ChangeLogItem{
Field: "assignee",
FromString: "Jonh White",
ToString: "Daniel Smith",
}
event.Changelog.Items = items
return event
}
func getEventResolvedIssue() jira.WebHookEvent {
event := getEventCreatedIssue()
event.Modifier.DisplayName = "Daniel Smith"
event.Issue.Fields.Assignee.DisplayName = "Daniel Smith"
event.Issue.Fields.Status.Name = "Resolved"
event.Event = "jira:issue_updated"
items := make([]jira.ChangeLogItem, 2);
items[0] = jira.ChangeLogItem{
Field: "status",
FromString: "In progress",
ToString: "Resolved",
}
event.Changelog.Items = items
return event
}