@@ -148,6 +148,49 @@ TEST-2 Story Open 2020-12-13 14:05:20
148148 assert .Equal (t , expected , b .String ())
149149}
150150
151+ func TestIssueRenderInCSVFormat (t * testing.T ) {
152+ var b bytes.Buffer
153+
154+ issue := IssueList {
155+ Project : "TEST" ,
156+ Server : "https://test.local" ,
157+ Data : getIssues (),
158+ Display : DisplayFormat {
159+ CSV : true ,
160+ NoHeaders : false ,
161+ NoTruncate : true ,
162+ },
163+ }
164+ assert .NoError (t , issue .renderCSV (& b ))
165+
166+ expected := `TYPE,KEY,SUMMARY,STATUS,ASSIGNEE,REPORTER,PRIORITY,RESOLUTION,CREATED,UPDATED,LABELS
167+ Bug,TEST-1,This is a test,Done,Person A,Person Z,High,Fixed,2020-12-13 14:05:20,2020-12-13 14:07:20,krakatit
168+ Story,TEST-2,This is another test,Open,,Person A,Normal,,2020-12-13 14:05:20,2020-12-13 14:07:20,"pat,mat"
169+ `
170+ assert .Equal (t , expected , b .String ())
171+ }
172+
173+ func TestIssueRenderInCSVFormatWithoutHeaders (t * testing.T ) {
174+ var b bytes.Buffer
175+
176+ issue := IssueList {
177+ Project : "TEST" ,
178+ Server : "https://test.local" ,
179+ Data : getIssues (),
180+ Display : DisplayFormat {
181+ CSV : true ,
182+ NoHeaders : true ,
183+ NoTruncate : true ,
184+ },
185+ }
186+ assert .NoError (t , issue .renderCSV (& b ))
187+
188+ expected := `Bug,TEST-1,This is a test,Done,Person A,Person Z,High,Fixed,2020-12-13 14:05:20,2020-12-13 14:07:20,krakatit
189+ Story,TEST-2,This is another test,Open,,Person A,Normal,,2020-12-13 14:05:20,2020-12-13 14:07:20,"pat,mat"
190+ `
191+ assert .Equal (t , expected , b .String ())
192+ }
193+
151194func getIssues () []* jira.Issue {
152195 return []* jira.Issue {
153196 {
0 commit comments