Skip to content

test: add View.Make/First render coverage for framework#1561 - #151

Open
goravel-coder wants to merge 1 commit into
masterfrom
bowen/test-pr-1561-view-render
Open

goravel-coder wants to merge 1 commit into
masterfrom
bowen/test-pr-1561-view-render

Conversation

@goravel-coder

@goravel-coder goravel-coder commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • ViewTestSuite now locks in rendering a view to a string outside an HTTP request: Make(...).Render() matches the driver's response body byte-for-byte for the same view, and resolves app views, package views registered with LoadViewsFrom(), and nested partials/layouts.
  • View.First is covered end to end through the new define_only.tmpl fixture — it skips missing and existing-but-non-renderable candidates, returns the first renderable one, and reports ViewNoneExist when none qualify; Template.With/Name/Data, struct and pointer-to-struct data, and the ViewTemplateNotExist/ViewInvalidData errors are asserted.
  • Pins github.com/goravel/framework to a temporary fork build of feat: [#773] add View.Make to render a template to a string framework#1561 so the new tests compile before that PR merges.

Closes https://github.com/goravel/goravel/issues/1561

Why

goravel/framework#1561 generalizes the view API so a template can be built and rendered outside an HTTP response: View.Make/View.First return a Template exposing Render, With, Name, and Data. This branch adds the missing example-level integration coverage for that contract, exercising it through the public facades.View() facade under both the gin and fiber drivers rather than reaching into framework internals.

// Render a struct-friendly view to a string — no HTTP response required.
template := facades.View().Make("greeting.tmpl", models.User{Name: "Goravel"})

html, err := template.Render()
if err != nil {
	return ctx.Response().String(http.StatusInternalServerError, err.Error())
}

return ctx.Response().String(http.StatusOK, html)

go.mod currently carries a temporary replace github.com/goravel/framework => github.com/darakanoit/framework v1.18.1-0.20260927233735-13001ebed1a1 (plus the indirect dependency bumps go mod tidy pulls in) so the suite compiles against the unmerged PR #1561. This fork pin is a pre-merge placeholder only, not the final dependency state: before this PR merges it must be swapped to the upstream github.com/goravel/framework@master pseudo-version and go mod tidy re-run so the github.com/darakanoit/framework lines leave go.sum.

@goravel-coder
goravel-coder requested a review from a team as a code owner September 25, 2026 02:44
@hwbrzzl
hwbrzzl force-pushed the bowen/test-pr-1561-view-render branch 2 times, most recently from bf62a50 to 9730836 Compare September 28, 2026 02:02
@hwbrzzl
hwbrzzl force-pushed the bowen/test-pr-1561-view-render branch from 9730836 to c597b17 Compare September 28, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant