Skip to content

Commit

Permalink
support Go v1.16 version (gin-gonic#2638)
Browse files Browse the repository at this point in the history
(cherry picked from commit 77649bc)
  • Loading branch information
thinkerou authored and Bisstocuz committed Nov 22, 2021
1 parent c0ac7f9 commit 45932c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Expand Up @@ -15,6 +15,10 @@ matrix:
- go: 1.15.x
env:
- TESTTAGS=nomsgpack
- go: 1.16.x
- go: 1.16.x
env:
- TESTTAGS=nomsgpack
- go: master

git:
Expand Down
8 changes: 6 additions & 2 deletions context_test.go
Expand Up @@ -1018,7 +1018,9 @@ func TestContextRenderFile(t *testing.T) {

assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), "func New() *Engine {")
assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type"))
// Content-Type='text/plain; charset=utf-8' when go version <= 1.16,
// else, Content-Type='text/x-go; charset=utf-8'
assert.NotEqual(t, "", w.Header().Get("Content-Type"))
}

func TestContextRenderFileFromFS(t *testing.T) {
Expand All @@ -1030,7 +1032,9 @@ func TestContextRenderFileFromFS(t *testing.T) {

assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), "func New() *Engine {")
assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type"))
// Content-Type='text/plain; charset=utf-8' when go version <= 1.16,
// else, Content-Type='text/x-go; charset=utf-8'
assert.NotEqual(t, "", w.Header().Get("Content-Type"))
assert.Equal(t, "/some/path", c.Request.URL.Path)
}

Expand Down
4 changes: 3 additions & 1 deletion routes_test.go
Expand Up @@ -360,7 +360,9 @@ func TestRouterMiddlewareAndStatic(t *testing.T) {

assert.Equal(t, http.StatusOK, w.Code)
assert.Contains(t, w.Body.String(), "package gin")
assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type"))
// Content-Type='text/plain; charset=utf-8' when go version <= 1.16,
// else, Content-Type='text/x-go; charset=utf-8'
assert.NotEqual(t, "", w.Header().Get("Content-Type"))
assert.NotEqual(t, w.Header().Get("Last-Modified"), "Mon, 02 Jan 2006 15:04:05 MST")
assert.Equal(t, "Mon, 02 Jan 2006 15:04:05 MST", w.Header().Get("Expires"))
assert.Equal(t, "Gin Framework", w.Header().Get("x-GIN"))
Expand Down

0 comments on commit 45932c4

Please sign in to comment.