Skip to content

Commit 7f7ddff

Browse files
committed
add a test for exporting the issues to excel
1 parent 305069a commit 7f7ddff

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/integration/issue_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,27 @@ func TestIssueReaction(t *testing.T) {
371371
session.MakeRequest(t, req, http.StatusOK)
372372
}
373373

374+
func TestIssueListExport(t *testing.T) {
375+
defer tests.PrepareTestEnv(t)()
376+
session := loginUser(t, "user2")
377+
_ = testNewIssue(t, session, "user2", "repo1", "Title", "Description")
378+
_ = testNewIssue(t, session, "user2", "repo1", "Title2", "Description2")
379+
_ = testNewIssue(t, session, "user2", "repo1", "Title3", "Description3")
380+
381+
// trying to export all open issues of the given repository
382+
req := NewRequestWithValues(t, "GET", fmt.Sprintf("/%s/%s/issues/export?%s", "user2", "repo1", "type=all&state=open"))
383+
resp := session.MakeRequest(t, req, http.StatusOK)
384+
385+
// Content-Type should be an Excel file (XLSX)
386+
ct := strings.Split(resp.Header().Get("Content-Type"), ";")[0]
387+
assert.Equal(t, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", ct)
388+
389+
// Content-Disposition should indicate attachment with .xlsx
390+
cd := resp.Header().Get("Content-Disposition")
391+
assert.Contains(t, cd, "attachment")
392+
assert.True(t, strings.Contains(cd, ".xlsx"))
393+
}
394+
374395
func TestIssueCrossReference(t *testing.T) {
375396
defer tests.PrepareTestEnv(t)()
376397

0 commit comments

Comments
 (0)