Files
gout/dataflow/dataflow_json_test.go
guonaihong faf5d11770 Set json escape html (#346)
* SetJSONNotEscape接口不转义HTML符号

* 完善文档

* 适应老的编译器

* 适应老版编译器
2022-12-18 22:31:07 +08:00

24 lines
846 B
Go

package dataflow
import (
"bytes"
"fmt"
"testing"
"github.com/guonaihong/gout/debug"
"github.com/stretchr/testify/assert"
)
func Test_SetJSONNotEscape(t *testing.T) {
ts := createGeneral("")
fmt.Println("url", ts.URL)
var buf bytes.Buffer
//POST(ts.URL).Debug(true).SetJSONNotEscape(map[string]any{"url": "http://www.com?a=b&c=d"}).Do()
POST(ts.URL).Debug(debug.ToWriter(&buf, false)).SetJSONNotEscape(map[string]interface{}{"url": "http://www.com?a=b&c=d"}).Do()
assert.True(t, bytes.Contains(buf.Bytes(), []byte("&")), buf.String())
buf.Reset()
//POST(ts.URL).Debug(true).SetJSON(map[string]any{"url": "http://www.com?a=b&c=d"}).Do()
POST(ts.URL).Debug(debug.ToWriter(&buf, false)).SetJSON(map[string]interface{}{"url": "http://www.com?a=b&c=d"}).Do()
assert.False(t, bytes.Contains(buf.Bytes(), []byte("&")), buf.String())
}