diff --git a/context_test.go b/context_test.go
index 47ea3e7b..9da98c6d 100644
--- a/context_test.go
+++ b/context_test.go
@@ -32,6 +32,8 @@ func TestContext(t *testing.T) {
userXML := `1Joe`
userXMLIndent := "_\n_?1\n_?Joe\n_"
+ var nonMarshallableChannel chan bool
+
req, _ := http.NewRequest(POST, "/", strings.NewReader(userJSON))
rec := httptest.NewRecorder()
c := NewContext(req, NewResponse(rec), New())
@@ -99,6 +101,13 @@ func TestContext(t *testing.T) {
assert.Equal(t, userJSON, rec.Body.String())
}
+ // JSON (error)
+ rec = httptest.NewRecorder()
+ c = NewContext(req, NewResponse(rec), New())
+ val := make(chan bool)
+ err = c.JSON(http.StatusOK, val)
+ assert.Error(t, err)
+
// JSONIndent
rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New())
@@ -109,6 +118,12 @@ func TestContext(t *testing.T) {
assert.Equal(t, userJSONIndent, rec.Body.String())
}
+ // JSONIndent (error)
+ rec = httptest.NewRecorder()
+ c = NewContext(req, NewResponse(rec), New())
+ err = c.JSONIndent(http.StatusOK, nonMarshallableChannel, "_", "?")
+ assert.Error(t, err)
+
// JSONP
rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New())
@@ -130,6 +145,12 @@ func TestContext(t *testing.T) {
assert.Equal(t, xml.Header+userXML, rec.Body.String())
}
+ // XML (error)
+ rec = httptest.NewRecorder()
+ c = NewContext(req, NewResponse(rec), New())
+ err = c.XML(http.StatusOK, nonMarshallableChannel)
+ assert.Error(t, err)
+
// XMLIndent
rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New())
@@ -140,6 +161,12 @@ func TestContext(t *testing.T) {
assert.Equal(t, xml.Header+userXMLIndent, rec.Body.String())
}
+ // XMLIndent (error)
+ rec = httptest.NewRecorder()
+ c = NewContext(req, NewResponse(rec), New())
+ err = c.XMLIndent(http.StatusOK, nonMarshallableChannel, "_", "?")
+ assert.Error(t, err)
+
// String
rec = httptest.NewRecorder()
c = NewContext(req, NewResponse(rec), New())