(t *testing.T)
| 1660 | } |
| 1661 | |
| 1662 | func TestContextNegotiationWithHTML(t *testing.T) { |
| 1663 | w := httptest.NewRecorder() |
| 1664 | c, router := CreateTestContext(w) |
| 1665 | c.Request, _ = http.NewRequest(http.MethodPost, "", nil) |
| 1666 | templ := template.Must(template.New("t").Parse(`Hello {{.name}}`)) |
| 1667 | router.SetHTMLTemplate(templ) |
| 1668 | |
| 1669 | c.Negotiate(http.StatusOK, Negotiate{ |
| 1670 | Offered: []string{MIMEHTML}, |
| 1671 | Data: H{"name": "gin"}, |
| 1672 | HTMLName: "t", |
| 1673 | }) |
| 1674 | |
| 1675 | assert.Equal(t, http.StatusOK, w.Code) |
| 1676 | assert.Equal(t, "Hello gin", w.Body.String()) |
| 1677 | assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type")) |
| 1678 | } |
| 1679 | |
| 1680 | func TestContextNegotiationWithPROTOBUF(t *testing.T) { |
| 1681 | w := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected