Skip to content

Commit

Permalink
testing: Simplify some integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jan 28, 2024
1 parent 6dedb4e commit 982d951
Show file tree
Hide file tree
Showing 32 changed files with 93 additions and 583 deletions.
7 changes: 1 addition & 6 deletions common/htime/htime_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ defaultContentLanguage = 'it'
{{ end }}
`

b := hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := hugolib.Test(t, files)

b.AssertFileContent("public/index.html", `
month: _gennaio_ weekday: _lunedì_
Expand Down
115 changes: 16 additions & 99 deletions hugolib/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,8 @@ title = "English Title"
[languages.en.params.comments]
title = "English Comments Title"
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

enSite := b.H.Sites[0]
b.Assert(enSite.Title(), qt.Equals, "English Title")
Expand Down Expand Up @@ -97,14 +90,8 @@ weight = 2
[languages.sv.params]
myparam = "svParamValue"
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

enSite := b.H.Sites[0]
svSite := b.H.Sites[1]
Expand Down Expand Up @@ -157,12 +144,7 @@ baseURL = "https://example.com"
[internal]
running = true
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.Assert(b.H.Conf.Running(), qt.Equals, false)
})
Expand Down Expand Up @@ -236,12 +218,7 @@ p1: {{ .Site.Params.p1 }}|
p2: {{ .Site.Params.p2 }}|
sub: {{ .Site.Params.sub }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/en/index.html", `
title: English Title|
Expand Down Expand Up @@ -987,12 +964,7 @@ params:
mainSections: {{ site.Params.mainSections }}
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
mainSections: []
Expand Down Expand Up @@ -1062,12 +1034,7 @@ Ein "Zitat" auf Deutsch.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "p1: p1base", "<p>A &ldquo;quote&rdquo; in English.</p>")
b.AssertFileContent("public/de/index.html", "p1: p1de", "<p>Ein &laquo;Zitat&raquo; auf Deutsch.</p>")
Expand Down Expand Up @@ -1129,12 +1096,7 @@ HTACCESS.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/.htaccess", "HTACCESS")
}
Expand All @@ -1150,12 +1112,7 @@ LanguageCode: {{ .Site.LanguageCode }}|{{ site.Language.LanguageCode }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "LanguageCode: en-US|en-US|")
}
Expand All @@ -1181,12 +1138,7 @@ Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "Home.")

Expand Down Expand Up @@ -1214,12 +1166,7 @@ Foo: {{ site.Params.foo }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "Foo: |")
})
Expand Down Expand Up @@ -1295,12 +1242,7 @@ Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.Assert(b.H.Configs.Base.Module.Mounts, qt.HasLen, 7)
b.Assert(b.H.Configs.LanguageConfigSlice[0].Module.Mounts, qt.HasLen, 7)
Expand All @@ -1321,12 +1263,7 @@ Foo.
-- layouts/index.html --
Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/en/index.html", "Home.")
b.AssertFileContent("public/en/foo/bar.txt", "Foo.")
Expand Down Expand Up @@ -1354,12 +1291,7 @@ Foo.
-- layouts/index.html --
Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/en/index.html", "Home.")
b.AssertFileContent("public/en/foo/bar.txt", "Foo.")
Expand Down Expand Up @@ -1387,12 +1319,7 @@ Foo.
-- layouts/index.html --
Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "Home.")
b.AssertFileContent("public/foo/bar.txt", "Foo.")
Expand All @@ -1417,12 +1344,7 @@ Home.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.Assert(len(b.H.Sites), qt.Equals, 1)
}
Expand Down Expand Up @@ -1557,12 +1479,7 @@ List.
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileExists("public/index.html", true)
b.AssertFileExists("public/categories/c1/index.html", true)
Expand Down
7 changes: 1 addition & 6 deletions hugolib/configdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ c = "c1"
-- layouts/index.html --
Params: {{ site.Params}}
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
Params: map[a:acp1 b:bc1 c:c1 d:dcp1]
Expand Down
14 changes: 2 additions & 12 deletions hugolib/content_render_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ outputs: ["rss"]
---
P3. [I'm an inline-style link](https://www.example.org)
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
P1: <p>P1. html-link: https://www.gohugo.io|</p>
Expand Down Expand Up @@ -163,12 +158,7 @@ P1 Fragments: {{ .Fragments.Identifiers }}|
{{ .Content}}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/p1/index.html", `
Self Fragments: [b c z]
Expand Down
9 changes: 1 addition & 8 deletions hugolib/datafiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
)

func TestData(t *testing.T) {

t.Run("with theme", func(t *testing.T) {
t.Parallel()

Expand All @@ -43,14 +42,8 @@ b: {{ site.Data.b.v1 }}|
cd: {{ site.Data.c.d.v1 }}|
d: {{ site.Data.d.v1 }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", "a: a_v1|\nb: b_v1|\ncd: c_d_v1|\nd: d_v1_theme|")

})
}
7 changes: 1 addition & 6 deletions hugolib/dates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,7 @@ mydata.date: {{ site.Data.mydata.date }}
Full time: {{ $p1Date | time.Format ":time_full" }}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
Future talks: 2
Expand Down
8 changes: 1 addition & 7 deletions hugolib/embedded_shortcodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ Foo: {{< param foo >}}
-- layouts/index.html --
Content: {{ .Content }}|
`
b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
<figure>
Expand All @@ -94,6 +89,5 @@ Foo: bar
`)

})
}
21 changes: 3 additions & 18 deletions hugolib/menu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,7 @@ Page IsAncestor Self: {{ $page.IsAncestor $page }}
Page IsDescendant Self: {{ $page.IsDescendant $page}}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/tests/index.html", `
Tests|/tests/|IsMenuCurrent = true|HasMenuCurrent = false
Expand Down Expand Up @@ -609,12 +604,7 @@ Menu Item: {{ $i }}: {{ .Pre }}{{ .Name }}{{ .Post }}|{{ .URL }}|
{{ end }}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
Menu Item: 0: <span>Home</span>|/|
Expand All @@ -640,12 +630,7 @@ Menu Item: {{ $i }}|{{ .URL }}|
{{ end }}
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/index.html", `
Menu Item: 0|/foo/posts|
Expand Down
7 changes: 1 addition & 6 deletions hugolib/page_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,7 @@ title: "empty"
|{{ .RawContent }}|
`

b := NewIntegrationTestBuilder(
IntegrationTestConfig{
T: t,
TxtarString: files,
},
).Build()
b := Test(t, files)

b.AssertFileContent("public/basic/index.html", "|**basic**|")
b.AssertFileContent("public/empty/index.html", "! title")
Expand Down
Loading

0 comments on commit 982d951

Please sign in to comment.