Skip to content

Commit

Permalink
improve render code coverage (gin-gonic#1474)
Browse files Browse the repository at this point in the history
all code coverage > 99%
  • Loading branch information
thinkerou authored and salamer committed Aug 18, 2018
1 parent 7d89b71 commit df04038
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ func TestRenderJsonpJSON(t *testing.T) {
assert.Equal(t, "application/javascript; charset=utf-8", w2.Header().Get("Content-Type"))
}

func TestRenderJsonpJSONError2(t *testing.T) {
w := httptest.NewRecorder()
data := map[string]interface{}{
"foo": "bar",
}
(JsonpJSON{"", data}).WriteContentType(w)
assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type"))

e := (JsonpJSON{"", data}).Render(w)
assert.NoError(t, e)

assert.Equal(t, "{\"foo\":\"bar\"}", w.Body.String())
assert.Equal(t, "application/javascript; charset=utf-8", w.Header().Get("Content-Type"))
}

func TestRenderJsonpJSONFail(t *testing.T) {
w := httptest.NewRecorder()
data := make(chan int)
Expand Down

0 comments on commit df04038

Please sign in to comment.