mirror of https://github.com/gin-gonic/gin.git
chore(go): Add support go 1.19 (#3272)
This commit is contained in:
parent
fa58bff301
commit
4c64f1c385
|
@ -31,7 +31,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
go: [1.16, 1.17, 1.18]
|
||||
go: [1.16, 1.17, 1.18, 1.19]
|
||||
test-tags: ['', '-tags nomsgpack', '-tags "sonic avx"', '-tags go_json']
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -28,6 +30,9 @@ func (i interceptedWriter) WriteHeader(code int) {
|
|||
}
|
||||
|
||||
func TestContextFormFileFailed17(t *testing.T) {
|
||||
if !isGo117OrGo118() {
|
||||
return
|
||||
}
|
||||
buf := new(bytes.Buffer)
|
||||
mw := multipart.NewWriter(buf)
|
||||
defer func(mw *multipart.Writer) {
|
||||
|
@ -75,3 +80,15 @@ func TestInterceptedHeader(t *testing.T) {
|
|||
assert.Equal(t, "", w.Result().Header.Get("X-Test"))
|
||||
assert.Equal(t, "present", w.Result().Header.Get("X-Test-2"))
|
||||
}
|
||||
|
||||
func isGo117OrGo118() bool {
|
||||
version := strings.Split(runtime.Version()[2:], ".")
|
||||
if len(version) >= 2 {
|
||||
x := version[0]
|
||||
y := version[1]
|
||||
if x == "1" && (y == "17" || y == "18") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright 2022 Gin Core Team. All rights reserved.
|
||||
// Use of this source code is governed by a MIT style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.19
|
||||
// +build go1.19
|
||||
|
||||
package gin
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestContextFormFileFailed19(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
mw := multipart.NewWriter(buf)
|
||||
mw.Close()
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest("POST", "/", nil)
|
||||
c.Request.Header.Set("Content-Type", mw.FormDataContentType())
|
||||
c.engine.MaxMultipartMemory = 8 << 20
|
||||
f, err := c.FormFile("file")
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, f)
|
||||
}
|
Loading…
Reference in New Issue