Skip to content

Commit

Permalink
hugolib: Add an asciidoc rebuild test case
Browse files Browse the repository at this point in the history
See #12375
  • Loading branch information
bep committed Apr 15, 2024
1 parent df11327 commit 74e9129
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions hugolib/rebuild_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/markup/asciidocext"
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/dartsass"
"github.com/gohugoio/hugo/resources/resource_transformers/tocss/scss"
)
Expand Down Expand Up @@ -1514,3 +1515,41 @@ MyTemplate: {{ partial "MyTemplate.html" . }}|

b.AssertFileContent("public/index.html", "MyTemplate: MyTemplate Edited")
}

func TestRebuildEditAsciidocContentFile(t *testing.T) {
if !asciidocext.Supports() {
t.Skip("skip asciidoc")
}
files := `
-- hugo.toml --
baseURL = "https://example.com"
disableLiveReload = true
disableKinds = ["taxonomy", "term", "sitemap", "robotsTXT", "404", "rss", "home", "section"]
[security]
[security.exec]
allow = ['^python$', '^rst2html.*', '^asciidoctor$']
-- content/posts/p1.adoc --
---
title: "P1"
---
P1 Content.
-- content/posts/p2.adoc --
---
title: "P2"
---
P2 Content.
-- layouts/_default/single.html --
Single: {{ .Title }}|{{ .Content }}|
`
b := TestRunning(t, files)
b.AssertFileContent("public/posts/p1/index.html",
"Single: P1|<div class=\"paragraph\">\n<p>P1 Content.</p>\n</div>\n|")
b.AssertRenderCountPage(2)
b.AssertRenderCountContent(2)

b.EditFileReplaceAll("content/posts/p1.adoc", "P1 Content.", "P1 Content Edited.").Build()

b.AssertFileContent("public/posts/p1/index.html", "Single: P1|<div class=\"paragraph\">\n<p>P1 Content Edited.</p>\n</div>\n|")
b.AssertRenderCountPage(1)
b.AssertRenderCountContent(1)
}

0 comments on commit 74e9129

Please sign in to comment.