Skip to content

Commit

Permalink
test: fix unit tests error on gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 12, 2022
1 parent efde02f commit c4a59d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions context_render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ func TestContext_Binary(t *testing.T) {
ss, ok := w.Header()["Content-Type"]
is.True(ok)
is.Equal(ss[0], "application/octet-stream")

ss, ok = w.Header()["Content-Disposition"]
is.True(ok)
is.Equal(ss[0], "inline; filename=new-name.md")
is.Equal("# readme", w.Body.String())
is.Contains(w.Body.String(), "# readme")
}

func TestContext_FileContent(t *testing.T) {
Expand All @@ -104,12 +105,13 @@ func TestContext_FileContent(t *testing.T) {
w := c.RawWriter().(*httptest.ResponseRecorder)
is.Equal(200, c.StatusCode())
is.Equal(200, w.Code)

ss, ok := w.Header()["Content-Type"]
is.True(ok)
// go 1.14.4 "text/markdown; charset=utf-8" does not contain "text/plain"
is.Contains(ss[0], "text/")
is.Equal("# readme", w.Body.String())
is.Equal(8, c.writer.Length())
is.Contains(w.Body.String(), "# readme")
is.True(8 < c.writer.Length())

c = mockContext("GET", "/site.md", nil, nil)
c.FileContent("testdata/not-exist.md")
Expand All @@ -130,10 +132,11 @@ func TestContext_Attachment(t *testing.T) {
ss, ok := w.Header()["Content-Type"]
is.True(ok)
is.Equal(ss[0], "application/octet-stream")

ss, ok = w.Header()["Content-Disposition"]
is.True(ok)
is.Equal(ss[0], "attachment; filename=new-name.md")
is.Equal("# readme", w.Body.String())
is.Contains(w.Body.String(), "# readme")
}

func TestContext_Inline(t *testing.T) {
Expand All @@ -148,8 +151,9 @@ func TestContext_Inline(t *testing.T) {
ss, ok := w.Header()["Content-Type"]
is.True(ok)
is.Equal(ss[0], "application/octet-stream")

ss, ok = w.Header()["Content-Disposition"]
is.True(ok)
is.Equal(ss[0], "inline; filename=new-name.md")
is.Equal("# readme", w.Body.String())
is.Contains(w.Body.String(), "# readme")
}
2 changes: 1 addition & 1 deletion testdata/site.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# readme

hello, world
hello, world

0 comments on commit c4a59d4

Please sign in to comment.