summaryrefslogtreecommitdiffstats
path: root/tpl
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-28 22:11:05 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2024-01-28 22:17:22 +0100
commit982d9513e71b3d48e20cfa38454a0e1215a8d963 (patch)
tree47ece9af143bfbd52fa0e5174f9349b8c04c3211 /tpl
parent6dedb4efc7b6a9fbe58a2daf0f77182638840fd9 (diff)
testing: Simplify some integration tests
Diffstat (limited to 'tpl')
-rw-r--r--tpl/collections/collections_integration_test.go42
-rw-r--r--tpl/images/images_integration_test.go7
-rw-r--r--tpl/page/page_integration_test.go7
-rw-r--r--tpl/partials/partials_integration_test.go42
-rw-r--r--tpl/resources/resources_integration_test.go12
-rw-r--r--tpl/templates/templates_integration_test.go21
6 files changed, 19 insertions, 112 deletions
diff --git a/tpl/collections/collections_integration_test.go b/tpl/collections/collections_integration_test.go
index 24727a12c..1bcabb447 100644
--- a/tpl/collections/collections_integration_test.go
+++ b/tpl/collections/collections_integration_test.go
@@ -32,12 +32,7 @@ baseURL = 'http://example.com/'
{{ return "foo"}}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
[foo foo foo]
@@ -89,12 +84,7 @@ func TestAppendSliceToASliceOfSlices(t *testing.T) {
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "[[a] [b] [c]]")
}
@@ -113,12 +103,7 @@ func TestAppendNilToSlice(t *testing.T) {
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "[a &lt;nil&gt;]")
}
@@ -180,12 +165,7 @@ title: "p3"
{{< lorem 60 >}}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Home: p1|p3|
@@ -218,12 +198,7 @@ foo: bc
{{- end -}}
</ul>
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "<ul><li>P1</li><li>P2</li></ul>")
}
@@ -246,12 +221,7 @@ boolf = false
{{ echoParam .Site.Params.footer "boolf" }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
"foo",
"42",
diff --git a/tpl/images/images_integration_test.go b/tpl/images/images_integration_test.go
index 81f35e39c..003422aed 100644
--- a/tpl/images/images_integration_test.go
+++ b/tpl/images/images_integration_test.go
@@ -40,12 +40,7 @@ imageConfig2 OK: {{ (imageConfig $path2).Width }}|
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
fileExists OK: true|
diff --git a/tpl/page/page_integration_test.go b/tpl/page/page_integration_test.go
index 632c3b64e..22f6323dd 100644
--- a/tpl/page/page_integration_test.go
+++ b/tpl/page/page_integration_test.go
@@ -196,12 +196,7 @@ title: "P1"
{{ .Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/p1/index.html", "<nav id=\"TableOfContents\"></nav> \n<h1 id=\"heading-1\">Heading 1</h1>")
}
diff --git a/tpl/partials/partials_integration_test.go b/tpl/partials/partials_integration_test.go
index e48f3bb20..f2bde29c3 100644
--- a/tpl/partials/partials_integration_test.go
+++ b/tpl/partials/partials_integration_test.go
@@ -39,12 +39,7 @@ partial: {{ partials.Include "foo.html" . }}
foo
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
partial: foo
@@ -64,12 +59,7 @@ partialCached: {{ partials.IncludeCached "foo.html" . }}
foo
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
partialCached: foo
@@ -93,12 +83,7 @@ P2
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
P2
@@ -130,12 +115,7 @@ P2
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
SHORT
@@ -180,12 +160,7 @@ D1
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
// fmt.Println(b.FileContent("public/index.html"))
@@ -340,12 +315,7 @@ FOO:{{ $r.Content }}
BAR
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "OO:BAR")
}
diff --git a/tpl/resources/resources_integration_test.go b/tpl/resources/resources_integration_test.go
index 02aa5d29d..5a3c29666 100644
--- a/tpl/resources/resources_integration_test.go
+++ b/tpl/resources/resources_integration_test.go
@@ -54,11 +54,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Image Orig: /blog/images/pixel.png|image/png|1|1|
@@ -112,11 +108,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Image OK
diff --git a/tpl/templates/templates_integration_test.go b/tpl/templates/templates_integration_test.go
index 7e0bcc824..301f783a5 100644
--- a/tpl/templates/templates_integration_test.go
+++ b/tpl/templates/templates_integration_test.go
@@ -34,12 +34,7 @@ partials/doesnotexist.html: {{ templates.Exists "partials/doesnotexist.html" }}
-- layouts/partials/foo.html --
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
index.html: true
@@ -69,12 +64,7 @@ post/doesnotexist.html: {{ templates.Exists "post/doesnotexist.html" }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
index.html: true
@@ -96,12 +86,7 @@ Home: {{ page.IsHome }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Home: true