package sitebuilder_test import ( "os" "path/filepath" "testing" "testing/fstest" "github.com/stretchr/testify/assert" "lmika.dev/lmika/weiro/models" "lmika.dev/lmika/weiro/models/pubmodel" "lmika.dev/lmika/weiro/providers/sitebuilder" ) func TestBuilder_BuildSite(t *testing.T) { t.Run("build site", func(t *testing.T) { tmpls := fstest.MapFS{ "posts_single.html": {Data: []byte(`{{ .HTML }}`)}, "posts_list.html": {Data: []byte(`{{ range .Posts}}{{.Post.Title}},{{ end }}`)}, "layout_main.html": {Data: []byte(`{{ .Body }}`)}, } site := pubmodel.Site{ BaseURL: "https://example.com", Posts: []*models.Post{ { Title: "Test Post", Slug: "/2026/02/18/test-post", Body: "This is a test post", }, { Title: "Another Post", Slug: "/2026/02/20/another-post", Body: "This is **another** test post", }, }, } wantFiles := map[string]string{ "2026/02/18/test-post/index.html": "

This is a test post

\n", "2026/02/20/another-post/index.html": "

This is another test post

\n", "index.html": "Test Post,Another Post,", } outDir := t.TempDir() b, err := sitebuilder.New(site, sitebuilder.Options{ TemplatesFS: tmpls, }) assert.NoError(t, err) err = b.BuildSite(outDir) assert.NoError(t, err) for file, content := range wantFiles { filePath := filepath.Join(outDir, file) fileContent, err := os.ReadFile(filePath) assert.NoError(t, err) assert.Equal(t, content, string(fileContent)) } }) }