gin/render/render_17_test.go
Michael Li b0275eda05 add sync.Pool to manager JSON,XML,YAML,ProtoBuf,MsgPack Render object.
add sync.Pool to manager JSON,XML,YAML,ProtoBuf,MsgPack Render object.
we can move JSON,XML,YAML,ProtoBuf,MsgPack Render implement to sub-module in Gin or other repository module based on this change.
2018-12-30 02:32:54 +08:00

30 lines
700 B
Go

// Copyright 2018 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.
// +build go1.7
package render
import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRenderPureJSON(t *testing.T) {
w := httptest.NewRecorder()
data := map[string]interface{}{
"foo": "bar",
"html": "<b>",
}
r := Default(PureJSONRenderType)
r.Setup(data)
err := r.Render(w)
Recycle(PureJSONRenderType, r)
assert.NoError(t, err)
assert.Equal(t, "{\"foo\":\"bar\",\"html\":\"<b>\"}\n", w.Body.String())
assert.Equal(t, "application/json; charset=utf-8", w.Header().Get("Content-Type"))
}