summaryrefslogtreecommitdiffstats
path: root/hugolib/rebuild_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib/rebuild_test.go')
-rw-r--r--hugolib/rebuild_test.go98
1 files changed, 81 insertions, 17 deletions
diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go
index ea7efcb6f..0db418ee1 100644
--- a/hugolib/rebuild_test.go
+++ b/hugolib/rebuild_test.go
@@ -53,6 +53,11 @@ title: "Home"
Home Content.
-- content/hometext.txt --
Home Text Content.
+-- content/myothersection/myothersectionpage.md --
+---
+title: "myothersectionpage"
+---
+myothersectionpage Content.
-- layouts/_default/single.html --
Single: {{ .Title }}|{{ .Content }}$
Resources: {{ range $i, $e := .Resources }}{{ $i }}:{{ .RelPermalink }}|{{ .Content }}|{{ end }}$
@@ -121,14 +126,23 @@ func TestRebuildEditTextFileInBranchBundle(t *testing.T) {
b.AssertRenderCountContent(1)
}
+func testRebuildBothWatchingAndRunning(t *testing.T, files string, withB func(b *IntegrationTestBuilder)) {
+ t.Helper()
+ for _, opt := range []TestOpt{TestOptWatching(), TestOptRunning()} {
+ b := Test(t, files, opt)
+ withB(b)
+ }
+}
+
func TestRebuildRenameTextFileInLeafBundle(t *testing.T) {
- b := TestRunning(t, rebuildFilesSimple)
- b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
+ testRebuildBothWatchingAndRunning(t, rebuildFilesSimple, func(b *IntegrationTestBuilder) {
+ b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
- b.RenameFile("content/mysection/mysectionbundle/mysectionbundletext.txt", "content/mysection/mysectionbundle/mysectionbundletext2.txt").Build()
- b.AssertFileContent("public/mysection/mysectionbundle/index.html", "mysectionbundletext2", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
- b.AssertRenderCountPage(3)
- b.AssertRenderCountContent(3)
+ b.RenameFile("content/mysection/mysectionbundle/mysectionbundletext.txt", "content/mysection/mysectionbundle/mysectionbundletext2.txt").Build()
+ b.AssertFileContent("public/mysection/mysectionbundle/index.html", "mysectionbundletext2", "My Section Bundle Text 2 Content.", "Len Resources: 2|")
+ b.AssertRenderCountPage(5)
+ b.AssertRenderCountContent(6)
+ })
}
func TestRebuilEditContentFileInLeafBundle(t *testing.T) {
@@ -138,6 +152,19 @@ func TestRebuilEditContentFileInLeafBundle(t *testing.T) {
b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Content Content Edited.")
}
+func TestRebuilEditContentFileThenAnother(t *testing.T) {
+ b := TestRunning(t, rebuildFilesSimple)
+ b.EditFileReplaceAll("content/mysection/mysectionbundle/mysectionbundlecontent.md", "Content Content.", "Content Content Edited.").Build()
+ b.AssertFileContent("public/mysection/mysectionbundle/index.html", "My Section Bundle Content Content Edited.")
+ b.AssertRenderCountPage(1)
+ b.AssertRenderCountContent(2)
+
+ b.EditFileReplaceAll("content/myothersection/myothersectionpage.md", "myothersectionpage Content.", "myothersectionpage Content Edited.").Build()
+ b.AssertFileContent("public/myothersection/myothersectionpage/index.html", "myothersectionpage Content Edited")
+ b.AssertRenderCountPage(1)
+ b.AssertRenderCountContent(1)
+}
+
func TestRebuildRenameTextFileInBranchBundle(t *testing.T) {
b := TestRunning(t, rebuildFilesSimple)
b.AssertFileContent("public/mysection/index.html", "My Section")
@@ -154,7 +181,7 @@ func TestRebuildRenameTextFileInHomeBundle(t *testing.T) {
b.RenameFile("content/hometext.txt", "content/hometext2.txt").Build()
b.AssertFileContent("public/index.html", "hometext2", "Home Text Content.")
- b.AssertRenderCountPage(2)
+ b.AssertRenderCountPage(3)
}
func TestRebuildRenameDirectoryWithLeafBundle(t *testing.T) {
@@ -170,7 +197,7 @@ func TestRebuildRenameDirectoryWithBranchBundle(t *testing.T) {
b.AssertFileContent("public/mysectionrenamed/index.html", "My Section")
b.AssertFileContent("public/mysectionrenamed/mysectionbundle/index.html", "My Section Bundle")
b.AssertFileContent("public/mysectionrenamed/mysectionbundle/mysectionbundletext.txt", "My Section Bundle Text 2 Content.")
- b.AssertRenderCountPage(2)
+ b.AssertRenderCountPage(3)
}
func TestRebuildRenameDirectoryWithRegularPageUsedInHome(t *testing.T) {
@@ -269,7 +296,7 @@ func TestRebuildRenameDirectoryWithBranchBundleFastRender(t *testing.T) {
b.AssertFileContent("public/mysectionrenamed/index.html", "My Section")
b.AssertFileContent("public/mysectionrenamed/mysectionbundle/index.html", "My Section Bundle")
b.AssertFileContent("public/mysectionrenamed/mysectionbundle/mysectionbundletext.txt", "My Section Bundle Text 2 Content.")
- b.AssertRenderCountPage(2)
+ b.AssertRenderCountPage(3)
}
func TestRebuilErrorRecovery(t *testing.T) {
@@ -367,8 +394,6 @@ My short.
}
func TestRebuildBaseof(t *testing.T) {
- t.Parallel()
-
files := `
-- hugo.toml --
title = "Hugo Site"
@@ -383,12 +408,13 @@ Baseof: {{ .Title }}|
Home: {{ .Title }}|{{ .Content }}|
{{ end }}
`
- b := Test(t, files, TestOptRunning())
- b.AssertFileContent("public/index.html", "Baseof: Hugo Site|", "Home: Hugo Site||")
- b.EditFileReplaceFunc("layouts/_default/baseof.html", func(s string) string {
- return strings.Replace(s, "Baseof", "Baseof Edited", 1)
- }).Build()
- b.AssertFileContent("public/index.html", "Baseof Edited: Hugo Site|", "Home: Hugo Site||")
+ testRebuildBothWatchingAndRunning(t, files, func(b *IntegrationTestBuilder) {
+ b.AssertFileContent("public/index.html", "Baseof: Hugo Site|", "Home: Hugo Site||")
+ b.EditFileReplaceFunc("layouts/_default/baseof.html", func(s string) string {
+ return strings.Replace(s, "Baseof", "Baseof Edited", 1)
+ }).Build()
+ b.AssertFileContent("public/index.html", "Baseof Edited: Hugo Site|", "Home: Hugo Site||")
+ })
}
func TestRebuildSingleWithBaseof(t *testing.T) {
@@ -1577,3 +1603,41 @@ title: p1
b.AddFiles("content/p2.md", "---\ntitle: p2\n---").Build()
b.AssertFileContent("public/index.html", "p1|p2|") // this test passes, which doesn't match reality
}
+
+func TestRebuildHomeThenPageIssue12436(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableKinds = ['sitemap','taxonomy','term']
+disableLiveReload = true
+-- layouts/_default/list.html --
+{{ .Content }}
+-- layouts/_default/single.html --
+{{ .Content }}
+-- content/_index.md --
+---
+title: home
+---
+home-content|
+-- content/p1/index.md --
+---
+title: p1
+---
+p1-content|
+`
+
+ b := TestRunning(t, files)
+
+ b.AssertFileContent("public/index.html", "home-content|")
+ b.AssertFileContent("public/p1/index.html", "p1-content|")
+ b.AssertRenderCountPage(3)
+
+ b.EditFileReplaceAll("content/_index.md", "home-content", "home-content-foo").Build()
+ b.AssertFileContent("public/index.html", "home-content-foo")
+ b.AssertRenderCountPage(2) // Home page rss + html
+
+ b.EditFileReplaceAll("content/p1/index.md", "p1-content", "p1-content-foo").Build()
+ b.AssertFileContent("public/p1/index.html", "p1-content-foo")
+}