Пример #1
0
func TestXmlResult(t *testing.T) {
	data := defaultUser()
	x := wk.Xml(data)
	var result wk.HttpResult = x
	t.Log("XmlResult", result)

	header := make(http.Header)
	body := &bytes.Buffer{}
	var render wk.Render = x

	err := render.Write(header, body)
	success(t, "xml write", err)
	equal(t, "xml header", wk.ContentTypeXml, header.Get(wk.HeaderContentType))
	equal(t, "xml body", toxml(data), body.String())
}
Пример #2
0
func TestJsonResult(t *testing.T) {
	data := defaultUser()
	j := wk.Json(data)
	var result wk.HttpResult = j
	t.Log("JsonResult", result)

	header := make(http.Header)
	body := &bytes.Buffer{}
	var render wk.Render = j

	err := render.Write(header, body)
	success(t, "json write", err)
	equal(t, "json header", wk.ContentTypeJson, header.Get(wk.HeaderContentType))
	equal(t, "json body", tojson(data), body.String())
}