summaryrefslogtreecommitdiffstats
path: root/hugolib/content_render_hooks_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-20 08:11:36 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-12-20 11:38:44 +0100
commit8a58ebb311fd079f65068e7e37725e4d43f17ab5 (patch)
treeb214284b27d2a2cf35ba0689bea688bdd0597e5f /hugolib/content_render_hooks_test.go
parent0453683816cfbc94e1e19c644f5f84213bb8cf35 (diff)
hugolib: Improve error and reload handling of hook templates in server mode
Fixes #6635
Diffstat (limited to 'hugolib/content_render_hooks_test.go')
-rw-r--r--hugolib/content_render_hooks_test.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/hugolib/content_render_hooks_test.go b/hugolib/content_render_hooks_test.go
index d206013ba..ee7a02074 100644
--- a/hugolib/content_render_hooks_test.go
+++ b/hugolib/content_render_hooks_test.go
@@ -158,6 +158,60 @@ SHORT3|
}
+func TestRenderHooksDeleteTemplate(t *testing.T) {
+ config := `
+baseURL="https://example.org"
+workingDir="/mywork"
+`
+ b := newTestSitesBuilder(t).WithWorkingDir("/mywork").WithConfigFile("toml", config).Running()
+ b.WithTemplatesAdded("_default/single.html", `{{ .Content }}`)
+ b.WithTemplatesAdded("_default/_markup/render-link.html", `html-render-link`)
+
+ b.WithContent("p1.md", `---
+title: P1
+---
+[First Link](https://www.google.com "Google's Homepage")
+
+`)
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/p1/index.html", `<p>html-render-link</p>`)
+
+ b.RemoveFiles(
+ "layouts/_default/_markup/render-link.html",
+ )
+
+ b.Build(BuildCfg{})
+ b.AssertFileContent("public/p1/index.html", `<p><a href="https://www.google.com" title="Google's Homepage">First Link</a></p>`)
+
+}
+
+func TestRenderHookAddTemplate(t *testing.T) {
+ config := `
+baseURL="https://example.org"
+workingDir="/mywork"
+`
+ b := newTestSitesBuilder(t).WithWorkingDir("/mywork").WithConfigFile("toml", config).Running()
+ b.WithTemplatesAdded("_default/single.html", `{{ .Content }}`)
+
+ b.WithContent("p1.md", `---
+title: P1
+---
+[First Link](https://www.google.com "Google's Homepage")
+
+`)
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/p1/index.html", `<p><a href="https://www.google.com" title="Google's Homepage">First Link</a></p>`)
+
+ b.EditFiles("layouts/_default/_markup/render-link.html", `html-render-link`)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/p1/index.html", `<p>html-render-link</p>`)
+
+}
+
func TestRenderHooksRSS(t *testing.T) {
b := newTestSitesBuilder(t)