Replace template dir file path hack with embed directive.

This commit is contained in:
mikestefanello 2023-12-10 09:33:34 -05:00
parent 11f5ddcee4
commit 29fbadbadd
7 changed files with 21 additions and 33 deletions

View file

@ -12,6 +12,7 @@ import (
"github.com/mikestefanello/pagoda/pkg/middleware"
"github.com/mikestefanello/pagoda/pkg/services"
"github.com/mikestefanello/pagoda/pkg/tests"
"github.com/mikestefanello/pagoda/templates"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@ -98,7 +99,7 @@ func TestController_RenderPage(t *testing.T) {
expectedTemplates := make(map[string]bool)
expectedTemplates[p.Name+config.TemplateExt] = true
expectedTemplates[p.Layout+config.TemplateExt] = true
components, err := os.ReadDir(c.TemplateRenderer.GetTemplatesPath() + "/components")
components, err := templates.Templates.ReadDir("components")
require.NoError(t, err)
for _, f := range components {
expectedTemplates[f.Name()] = true
@ -131,7 +132,7 @@ func TestController_RenderPage(t *testing.T) {
expectedTemplates := make(map[string]bool)
expectedTemplates[p.Name+config.TemplateExt] = true
expectedTemplates["htmx"+config.TemplateExt] = true
components, err := os.ReadDir(c.TemplateRenderer.GetTemplatesPath() + "/components")
components, err := templates.Templates.ReadDir("components")
require.NoError(t, err)
for _, f := range components {
expectedTemplates[f.Name()] = true