mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-23 18:22:23 +08:00
add test cases for YAML
This commit is contained in:
parent
a94da2a7b7
commit
dc56b1a1bb
@ -7,6 +7,7 @@ package render
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@ -170,6 +171,19 @@ b:
|
||||
assert.Equal(t, w.Header().Get("Content-Type"), "application/x-yaml; charset=utf-8")
|
||||
}
|
||||
|
||||
type fail struct{}
|
||||
|
||||
// Hook MarshalYAML
|
||||
func (ft *fail) MarshalYAML() (interface{}, error) {
|
||||
return nil, errors.New("fail")
|
||||
}
|
||||
|
||||
func TestRenderYAMLFail(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
err := (YAML{&fail{}}).Render(w)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestRenderXML(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
data := xmlmap{
|
||||
|
Loading…
x
Reference in New Issue
Block a user