test support go1.18 (#2990)
This commit is contained in:
+18
-18
@@ -24,7 +24,7 @@ import (
|
||||
|
||||
func TestRenderJSON(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
"html": "<b>",
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func TestRenderJSONPanics(t *testing.T) {
|
||||
|
||||
func TestRenderIndentedJSON(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
"bar": "foo",
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func TestRenderIndentedJSONPanics(t *testing.T) {
|
||||
|
||||
func TestRenderSecureJSON(t *testing.T) {
|
||||
w1 := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestRenderSecureJSON(t *testing.T) {
|
||||
assert.Equal(t, "application/json; charset=utf-8", w1.Header().Get("Content-Type"))
|
||||
|
||||
w2 := httptest.NewRecorder()
|
||||
datas := []map[string]interface{}{{
|
||||
datas := []map[string]any{{
|
||||
"foo": "bar",
|
||||
}, {
|
||||
"bar": "foo",
|
||||
@@ -109,7 +109,7 @@ func TestRenderSecureJSONFail(t *testing.T) {
|
||||
|
||||
func TestRenderJsonpJSON(t *testing.T) {
|
||||
w1 := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func TestRenderJsonpJSON(t *testing.T) {
|
||||
assert.Equal(t, "application/javascript; charset=utf-8", w1.Header().Get("Content-Type"))
|
||||
|
||||
w2 := httptest.NewRecorder()
|
||||
datas := []map[string]interface{}{{
|
||||
datas := []map[string]any{{
|
||||
"foo": "bar",
|
||||
}, {
|
||||
"bar": "foo",
|
||||
@@ -137,7 +137,7 @@ func TestRenderJsonpJSON(t *testing.T) {
|
||||
|
||||
func TestRenderJsonpJSONError2(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
}
|
||||
(JsonpJSON{"", data}).WriteContentType(w)
|
||||
@@ -161,7 +161,7 @@ func TestRenderJsonpJSONFail(t *testing.T) {
|
||||
|
||||
func TestRenderAsciiJSON(t *testing.T) {
|
||||
w1 := httptest.NewRecorder()
|
||||
data1 := map[string]interface{}{
|
||||
data1 := map[string]any{
|
||||
"lang": "GO语言",
|
||||
"tag": "<br>",
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func TestRenderAsciiJSONFail(t *testing.T) {
|
||||
|
||||
func TestRenderPureJSON(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
data := map[string]interface{}{
|
||||
data := map[string]any{
|
||||
"foo": "bar",
|
||||
"html": "<b>",
|
||||
}
|
||||
@@ -200,7 +200,7 @@ func TestRenderPureJSON(t *testing.T) {
|
||||
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
|
||||
}
|
||||
|
||||
type xmlmap map[string]interface{}
|
||||
type xmlmap map[string]any
|
||||
|
||||
// Allows type H to be used with xml.Marshal
|
||||
func (h xmlmap) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||
@@ -244,7 +244,7 @@ b:
|
||||
type fail struct{}
|
||||
|
||||
// Hook MarshalYAML
|
||||
func (ft *fail) MarshalYAML() (interface{}, error) {
|
||||
func (ft *fail) MarshalYAML() (any, error) {
|
||||
return nil, errors.New("fail")
|
||||
}
|
||||
|
||||
@@ -358,13 +358,13 @@ func TestRenderString(t *testing.T) {
|
||||
|
||||
(String{
|
||||
Format: "hello %s %d",
|
||||
Data: []interface{}{},
|
||||
Data: []any{},
|
||||
}).WriteContentType(w)
|
||||
assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type"))
|
||||
|
||||
err := (String{
|
||||
Format: "hola %s %d",
|
||||
Data: []interface{}{"manu", 2},
|
||||
Data: []any{"manu", 2},
|
||||
}).Render(w)
|
||||
|
||||
assert.NoError(t, err)
|
||||
@@ -377,7 +377,7 @@ func TestRenderStringLenZero(t *testing.T) {
|
||||
|
||||
err := (String{
|
||||
Format: "hola %s %d",
|
||||
Data: []interface{}{},
|
||||
Data: []any{},
|
||||
}).Render(w)
|
||||
|
||||
assert.NoError(t, err)
|
||||
@@ -390,7 +390,7 @@ func TestRenderHTMLTemplate(t *testing.T) {
|
||||
templ := template.Must(template.New("t").Parse(`Hello {{.name}}`))
|
||||
|
||||
htmlRender := HTMLProduction{Template: templ}
|
||||
instance := htmlRender.Instance("t", map[string]interface{}{
|
||||
instance := htmlRender.Instance("t", map[string]any{
|
||||
"name": "alexandernyquist",
|
||||
})
|
||||
|
||||
@@ -406,7 +406,7 @@ func TestRenderHTMLTemplateEmptyName(t *testing.T) {
|
||||
templ := template.Must(template.New("").Parse(`Hello {{.name}}`))
|
||||
|
||||
htmlRender := HTMLProduction{Template: templ}
|
||||
instance := htmlRender.Instance("", map[string]interface{}{
|
||||
instance := htmlRender.Instance("", map[string]any{
|
||||
"name": "alexandernyquist",
|
||||
})
|
||||
|
||||
@@ -425,7 +425,7 @@ func TestRenderHTMLDebugFiles(t *testing.T) {
|
||||
Delims: Delims{Left: "{[{", Right: "}]}"},
|
||||
FuncMap: nil,
|
||||
}
|
||||
instance := htmlRender.Instance("hello.tmpl", map[string]interface{}{
|
||||
instance := htmlRender.Instance("hello.tmpl", map[string]any{
|
||||
"name": "thinkerou",
|
||||
})
|
||||
|
||||
@@ -444,7 +444,7 @@ func TestRenderHTMLDebugGlob(t *testing.T) {
|
||||
Delims: Delims{Left: "{[{", Right: "}]}"},
|
||||
FuncMap: nil,
|
||||
}
|
||||
instance := htmlRender.Instance("hello.tmpl", map[string]interface{}{
|
||||
instance := htmlRender.Instance("hello.tmpl", map[string]any{
|
||||
"name": "thinkerou",
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user