(t *testing.T)
| 105 | } |
| 106 | |
| 107 | func TestRender_HTML_SharedPartial(t *testing.T) { |
| 108 | dir := makeViewDir(t, map[string]string{ |
| 109 | "nav.html": `{{define "nav"}}<nav>Menu</nav>{{end}}`, |
| 110 | "index.html": `{{template "nav" .}}<main>{{.Body}}</main>`, |
| 111 | }) |
| 112 | |
| 113 | server := setupServer(t, dir) |
| 114 | server.Get("/", func(c *pine.Ctx) error { |
| 115 | return c.Render("index.html", map[string]string{"Body": "content"}) |
| 116 | }) |
| 117 | |
| 118 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 119 | rr := httptest.NewRecorder() |
| 120 | server.ServeHTTP(rr, req) |
| 121 | |
| 122 | body := rr.Body.String() |
| 123 | if !strings.Contains(body, "<nav>Menu</nav>") { |
| 124 | t.Errorf("expected nav partial in body, got %q", body) |
| 125 | } |
| 126 | if !strings.Contains(body, "<main>content</main>") { |
| 127 | t.Errorf("expected main content in body, got %q", body) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | func TestRender_NoEngine_ReturnsError(t *testing.T) { |
| 132 | server := pine.New() // no engine configured |
nothing calls this directly
no test coverage detected