@@ -100,19 +100,45 @@ func TestSearchExistingIssue(t *testing.T) {
100100 title string
101101 cfg * config.JiraConfig
102102 groupKey string
103+ firing bool
103104 expectedJQL string
104105 expectedIssue * issue
105106 expectedErr bool
106107 expectedRetry bool
107108 }{
108109 {
109- title : "search existing issue with project template" ,
110+ title : "search existing issue with project template for firing alert " ,
110111 cfg : & config.JiraConfig {
111112 Summary : `{{ template "jira.default.summary" . }}` ,
112113 Description : `{{ template "jira.default.description" . }}` ,
113114 Project : `{{ .CommonLabels.project }}` ,
114115 },
115116 groupKey : "1" ,
117+ firing : true ,
118+ expectedJQL : `statusCategory != Done and project="PROJ" and labels="ALERT{1}" order by status ASC,resolutiondate DESC` ,
119+ },
120+ {
121+ title : "search existing issue with reopen duration for firing alert" ,
122+ cfg : & config.JiraConfig {
123+ Summary : `{{ template "jira.default.summary" . }}` ,
124+ Description : `{{ template "jira.default.description" . }}` ,
125+ Project : `{{ .CommonLabels.project }}` ,
126+ ReopenDuration : model .Duration (60 * time .Minute ),
127+ ReopenTransition : "REOPEN" ,
128+ },
129+ groupKey : "1" ,
130+ firing : true ,
131+ expectedJQL : `(resolutiondate is EMPTY OR resolutiondate >= -60m) and project="PROJ" and labels="ALERT{1}" order by status ASC,resolutiondate DESC` ,
132+ },
133+ {
134+ title : "search existing issue for resolved alert" ,
135+ cfg : & config.JiraConfig {
136+ Summary : `{{ template "jira.default.summary" . }}` ,
137+ Description : `{{ template "jira.default.description" . }}` ,
138+ Project : `{{ .CommonLabels.project }}` ,
139+ },
140+ groupKey : "1" ,
141+ firing : false ,
116142 expectedJQL : `statusCategory != Done and project="PROJ" and labels="ALERT{1}" order by status ASC,resolutiondate DESC` ,
117143 },
118144 } {
@@ -147,7 +173,7 @@ func TestSearchExistingIssue(t *testing.T) {
147173 return tmplText (tmpl ), tmplTextErr
148174 }
149175
150- issue , retry , err := pd .searchExistingIssue (ctx , logger , tc .groupKey , true , tmplTextFunc )
176+ issue , retry , err := pd .searchExistingIssue (ctx , logger , tc .groupKey , tc . firing , tmplTextFunc )
151177 if tc .expectedErr {
152178 require .Error (t , err )
153179 } else {
0 commit comments