"testing"
"time"
- "github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t, TxtarString: files, RunGC: true, NeedsOsFS: true},
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+ c.RunGC = true
+ }))
_, err := b.H.BaseFs.ResourcesCache.Stat(filepath.Join("_gen", "images"))
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t, TxtarString: files, Running: true, RunGC: true, NeedsOsFS: true, LogLevel: logg.LevelInfo},
- ).Build()
+ b := hugolib.TestRunning(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+ c.RunGC = true
+ }))
b.Assert(b.GCCount, qt.Equals, 0)
b.Assert(b.H, qt.IsNotNil)
Title: {{ .Title }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t, TxtarString: files},
- ).Build()
+ b := hugolib.Test(t, files)
// b.AssertFileContent("public/p1/index.html", "Title: p1")
logI18nWarnings = true
logPathWarnings = true
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t, TxtarString: files},
- ).Build()
+ b := hugolib.Test(t, files)
conf := b.H.Configs.Base
[languages.sv]
weight = 2
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `default language "sv" is disabled`)
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Environ: []string{"HUGO_PARAMS_P2=p2env", "HUGO_PARAMS_PM2_PM21=pm21env", "HUGO_PARAMS_PM3_PM31=pm31env"},
- },
- ).Build()
+ b := Test(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.Environ = []string{"HUGO_PARAMS_P2=p2env", "HUGO_PARAMS_PM2_PM21=pm21env", "HUGO_PARAMS_PM3_PM31=pm31env"}
+ }))
b.AssertFileContent("public/index.html", "p1: p1base\np2: p2env\npm21: pm21env\npm22: pm22base\npm31: pm31env")
})
for i, v := range environ {
environ[i] = strings.ReplaceAll(v, " ", delim)
}
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Environ: environ,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender(), TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.Environ = environ
+ }))
conf := b.H.Configs.Base
b.Assert(conf.DisableLanguages, qt.DeepEquals, []string{"no", "sv"})
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "Configured defaultMarkdownHandler \"blackfriday\" not found. Did you mean to use goldmark? Blackfriday was removed in Hugo v0.100.0.")
files := strings.ReplaceAll(filesTemplate, "hugo.toml", configName)
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html",
files = strings.ReplaceAll(files, "WEIGHT_SV", "2")
cfg := config.New()
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BaseCfg: cfg,
- },
- ).BuildE()
+ b, err := TestE(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.BaseCfg = cfg
+ }))
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html", "Home: en|2|")
for range 20 {
cfg := config.New()
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BaseCfg: cfg,
- },
- ).BuildE()
+ b, err := TestE(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.BaseCfg = cfg
+ }))
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html", "Home: en|2|")
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/myindex.html", "Home.")
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html", `
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- },
- ).Build()
+ b := Test(t, files, TestOptWarn())
b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 1)
WorkingDir: {{ hugo.WorkingDir }}|
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- WorkingDir: "myworkingdir",
- },
- ).Build()
+ b := Test(t, files, TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.WorkingDir = "myworkingdir"
+ }))
b.AssertFileContent("public/index.html", `
WorkingDir: myworkingdir|
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNil)
b.AssertFileContent("public/index.html", `
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "invalid language configuration ")
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `defaultContentLanguage "sv" not found in languages configuration`)
env = defaultEnv
}
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Environ: env,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender(), TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.Environ = env
+ }))
outputs := b.H.Configs.Base.Outputs
if env == nil {
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: c,
- TxtarString: files,
- }).Build()
+ b := Test(c, files)
b.AssertFileContent("public/index.html", "Home: Integration Test|")
}
os.Chdir(wd)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- WorkingDir: tmpDir,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+ c.WorkingDir = tmpDir
+ }))
bfs := b.H.BaseFs
watchFilenames := bfs.WatchFilenames()
---
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- WorkingDir: tempDir,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+ c.WorkingDir = tempDir
+ }))
abs1 := filepath.Join(tempDir, "content", "foo.md")
rel, abs2, err := b.H.BaseFs.AbsProjectContentDir("foo.md")
Mixed: {{ printf "%T" .Params.mixed }} {{ range .Params.mixed }}Mixed: {{ fmt.Printf "%[1]v (%[1]T)" . }}|{{ end }}
Strings: {{ printf "%T" .Params.strings }} {{ range .Params.strings }}Strings: {{ fmt.Printf "%[1]v (%[1]T)" . }}|{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- b.Build()
+ b := Test(t, files)
b.AssertFileContent("public/post/one/index.html", "Ints: []interface {} Int: 1 (uint64)|Int: 2 (uint64)|Int: 3 (uint64)|")
b.AssertFileContent("public/post/one/index.html", "Mixed: []interface {} Mixed: 1 (string)|Mixed: 2 (uint64)|Mixed: 3 (uint64)|")
Home: {{ .Title }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- // LogLevel: logg.LevelTrace,
- },
- ).Build()
+ b := Test(t, files)
b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 0)
b.AssertFileContent("public/index.html", `Hello`)
`
- b := NewIntegrationTestBuilder(IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- // Verbose: true,
- // LogLevel: logg.LevelTrace,
- }).Build()
+ b := Test(t, files, TestOptOsFs())
b.AssertFileContent("public/en/index.html",
"Home: en|home|/en/|Home in English|<p>Home Content.</p>\n|HTML",
// This is just a test to verify that BenchmarkBaseline is working as intended.
func TestBenchmarkBaseline(t *testing.T) {
- cfg := IntegrationTestConfig{
- T: t,
- TxtarString: benchmarkBaselineFiles(true),
- }
- b := NewIntegrationTestBuilder(cfg).Build()
+ b := Test(t, benchmarkBaselineFiles(true))
b.Assert(len(b.H.Sites), qt.Equals, 4)
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 161)
<ul>{{ range .AllTranslations }}<li>{{ .Title }}-{{ .Lang }}</li>{{ end }}</ul>
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
// Kind home
b.AssertFileContent("public/en/index.html",
{{ "something" | .RenderString $opts }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- _, err := b.BuildE()
+ b, err := hugolib.TestE(t, files)
+ _ = b
want := `no content renderer found for markup "foo"`
if !strings.Contains(err.Error(), want) {
{{ (site.GetPage "/films").Title }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "tags\nfiction\nbooks\nFilms")
}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- TxtarString: files,
- T: t,
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/en/p1/index.html", "HTML")
b.AssertFileContent("public/en/p1/index.json", "ToC: <nav id=\"TableOfContents\">\n <ul>\n <li><a href=\"#heading-1-fr\">Heading 1 FR</a></li>\n </ul>\n</nav>\nFragments : [heading-1-fr]")
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- TxtarString: files,
- T: t,
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/p1/index.html", "Fragments: [heading-p1-1 heading-p2-1 heading-p2-2]|")
b.AssertFileContent("public/p2/index.html", "Fragments: [heading-p2-1 heading-p2-2]|")
homePath := fmt.Sprintf("_index.%s", e.ext)
files.WriteString(fmt.Sprintf("-- content/%s --\n%s\n", homePath, homePage))
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files.String(),
- NeedsOsFS: true,
- BaseCfg: cfg,
- },
- ).Build()
+ b := Test(t, files.String(), TestOptOsFs(), TestOptWithConfig(func(c *IntegrationTestConfig) { c.BaseCfg = cfg }))
s := b.H.Sites[0]
-- content/simple.md --
` + simplePageWithSummaryDelimiterAndMarkdownThatCrossesBorder + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
-- content/tocpage.md --
` + pageWithToC + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
-- content/simple.md --
` + simplePageRFC3339Date + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
-- content/section/2012-02-22-slug.md --
` + fmt.Sprintf(pageTemplate, 2, "slug: aslug") + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true, // Needed for fileModTime
- },
- ).Build()
+ b := Test(t, files, TestOptOsFs())
s := b.H.Sites[0]
b.Assert(len(s.RegularPages()), qt.Equals, 2)
-- content/` + test.path + ` --
` + test.content + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
s := b.H.Sites[0]
b.Assert(len(s.RegularPages()), qt.Equals, 1)
-- content/simple.md --
` + utf8BOM + simplePage + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
{{< scratch >}}
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNil)
+++
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html",
"Author page: Ernest Miller Hemingway",
-- content/page.md --
` + content + `
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/page/index.html",
`<nav id="TableOfContents">
---
`
- b := NewIntegrationTestBuilder(IntegrationTestConfig{
- T: t,
- TxtarString: files,
- }).Build()
+ b := Test(t, files)
p1 := b.H.Sites[0].RegularPages()[0]
p2 := b.H.Sites[0].RegularPages()[1]
{{ .Render }}
`
- b, err := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := TestE(t, files)
b.Assert(err, qt.IsNotNil)
}
HEADLESS1: {{ $headless1.Title }}|{{ $headless1.RelPermalink }}|{{ len $headless1.Resources }}|
HEADLESS2: {{ $headless2.Title }}{{ $headless2.RelPermalink }}|{{ len $headless2.Resources }}|
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
HEADLESS1: My Headless Bundle1||1|
/README.md: {{ with .GetPage "/README.md" }}{{ .Title }}{{ end }}|
{{ .Content }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html",
`
NOT FOUND
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `Docs p1: p1`)
b.AssertFileContent("public/en/index.html", `NOT FOUND`)
Sect1 RegularPagesRecursive: {{ range $sect1.RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
Sect1 RegularPagesRecursive: page:/docs/sect1/ps1/|page:/docs/sect1/ps2/|page:/docs/sect1/sect1_s2/ps2_1/||End.
RegularPagesRecursive: {{ range .RegularPagesRecursive }}{{ .Kind }}:{{ .RelPermalink}}|{{ end }}|End.
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- }).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `RegularPagesRecursive: page:/p1/|page:/post/p2/||End.`)
}
"testing"
"time"
- "github.com/bep/logg"
"github.com/fortytw2/leaktest"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/types"
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- Verbose: false,
- BuildCfg: BuildCfg{
- testCounters: &buildCounters{},
- },
- LogLevel: logg.LevelWarn,
- },
- ).Build()
+ b := TestRunning(t, files,
+ TestOptWarn(),
+ TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.BuildCfg = BuildCfg{testCounters: &buildCounters{}}
+ }),
+ )
// When running the server, this is done on shutdown.
// Do this here to satisfy the leak detector above.
testCounters := &buildCounters{}
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- // LogLevel: logg.LevelTrace,
- // Verbose: true,
- BuildCfg: BuildCfg{
- testCounters: testCounters,
- },
- },
- ).Build()
+ b := TestRunning(t, files,
+ TestOptWithConfig(func(c *IntegrationTestConfig) {
+ c.BuildCfg = BuildCfg{testCounters: testCounters}
+ }),
+ )
b.AssertFileContent("public/index.html", `<script src="/main.js"></script>`)
b.AssertFileContent("public/p1/index.html", "<script>\n\"console.log(\\\"Hello\\\");\"\n</script>")
foo();
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- // LogLevel: logg.LevelTrace,
- NeedsOsFS: true,
- },
- ).Build()
+ b := TestRunning(t, files,
+ TestOptOsFs(),
+ )
b.AssertFileContent("public/index.html", "Home.", "Hello", "Foo")
// Edit the imported file.
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- // LogLevel: logg.LevelDebug,
- },
- ).Build()
+ b := TestRunning(t, files,
+ TestOptOsFs(),
+ TestOptWithNpmInstall(),
+ )
b.AssertFileContent("public/index.html", "Home.", "<style>body {\n\tbackground: red;\n}</style>")
b.AssertFileContent("public/p1/index.html", "Single.", "/css/main.css")
runTest := func(transpiler string) {
t.Run(transpiler, func(t *testing.T) {
files := strings.Replace(filesTemplate, "TRANSPILER", transpiler, 1)
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- NeedsOsFS: true,
- },
- ).Build()
+ b := TestRunning(t, files,
+ TestOptOsFs(),
+ )
b.AssertFileContent("public/index.html", "Home.", "background: red")
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- Running: true,
- },
- ).Build()
+ b := TestRunning(t, files)
b.AssertNoRenderShortcodesArtifacts()
b.AssertFileContent("public/p1/index.html", "Original")
`
t.Run("Basic", func(t *testing.T) {
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: filesTemplate,
- },
- ).Build()
+ b := Test(t, filesTemplate)
b.AssertFileContent("public/p1/index.html",
"<p>Markdown: 1. Item Mark2 1</p>\n<ol>\n<li>Item Mark2 2\n<ol>\n<li>Item Mark2 2-1</li>\n</ol>\n</li>\n<li>Item Mark2 3|",
})
t.Run("Edit shortcode", func(t *testing.T) {
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: filesTemplate,
- Running: true,
- },
- ).Build()
+ b := TestRunning(t, filesTemplate)
b.EditFiles("layouts/_shortcodes/myhthml.html", "Edit shortcode").Build()
files := test.files
files = strings.ReplaceAll(files, "HTTPTEST_SERVER_URL", ts.URL)
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
test.assert(b)
})
baseURL = "http://auth/bub"
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
})
baseURL = "http://auth/bub"
buildDrafts = true
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 2)
})
baseURL = "http://auth/bub"
buildFuture = true
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 2)
})
buildDrafts = true
buildFuture = true
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 4)
})
}
# doc5
*some content*
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(b.H.Sites[0].Lastmod().IsZero(), qt.Equals, false)
b.Assert(b.H.Sites[0].Lastmod().Year(), qt.Equals, 2017)
# doc1
*some content*
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{SkipRender: true},
- },
- ).Build()
+ b := Test(t, files, TestOptSkipRender())
b.Assert(len(b.H.Sites[0].RegularPages()), qt.Equals, 1)
}
baseURL = "http://auth/bub"
uglyURLs = true
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", "Home Sweet Home.")
b.AssertFileContent("public/sect/doc1.html", "<h1 id=\"title\">title</h1>\n<p>some <em>content</em></p>\n")
baseURL = "http://auth/bub"
uglyURLs = false
` + basefiles
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", "Home Sweet Home.")
b.AssertFileContent("public/sect/doc1/index.html", "<h1 id=\"title\">title</h1>\n<p>some <em>content</em></p>\n")
Page Content
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/page/index.html", "Base: Hi!?")
}
title: The Page
---
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/blog/p1/index.html", `single`)
b.AssertFileContent("public/blog/index.html", `list`)
Bonjour
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `Base:
Bonjour`)
title: P1
---
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `List: Home Sweet Home`)
b.AssertFileContent("public/p1/index.html", `Single: P1`)
title: My Page
---
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/en/index.html", `Baseof en: Main Home En`)
b.AssertFileContent("public/fr/index.html", `Baseof fr: Main Home Fr`)
Sites: {{ site.Sites.Default.Home.Language.Lang }}
Hugo: {{ hugo.Generator }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/en/index.html",
"Site: en / en / http://example.com/blog",
adder: 70: {{ partial "dict.tpl" (dict "adder" 28) }}
complex: 80: {{ partial "complex.tpl" 38 }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
add42: 50: 50
{{ end }}
-- content/p.md --
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html",
`
-- layouts/_partials/p1.html --
partial: {{ . }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
Partial cached1: partial: input1
title: p1
---
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
if: Zero: OK
| upper
}}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
<script type="application/ld+json">{"@type":"WebPage","headline":"a \u0026 b"}</script>
{{ return $value }}
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html",
`
{{ return $value }}
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html",
`
This is single main
{{ end }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `
Home Header
{{ $a := apply $b "strings.Trim" "." " " }}
a: {{ $a }}
`
- b := NewIntegrationTestBuilder(
- IntegrationTestConfig{
- T: t,
- TxtarString: files,
- BuildCfg: BuildCfg{},
- },
- ).Build()
+ b := Test(t, files)
b.AssertFileContent("public/index.html", `a: [a b c]`)
}
qt "github.com/frankban/quicktest"
- "github.com/bep/logg"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- TxtarString: files,
- Running: true,
- LogLevel: logg.LevelWarn,
- // PrintAndKeepTempDir: true,
- }).Build()
+ b := hugolib.TestRunning(t, files, hugolib.TestOptWithOSFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptWarn())
b.AssertFileContent("public/index.html",
"mains: 0: /mybundle/mains.js",
`
testLanguage := func(language, expect string) {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: strings.ReplaceAll(files, "LANGUAGE", language),
- },
- ).Build()
+ b := hugolib.Test(t, strings.ReplaceAll(files, "LANGUAGE", language))
b.AssertFileContent("public/p1/index.html", expect)
}
} {
t.Run(test.name, func(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: strings.ReplaceAll(files, "BLOCK", test.markdown),
- },
- ).Build()
+ b := hugolib.Test(t, strings.ReplaceAll(files, "BLOCK", test.markdown))
b.AssertFileContent("public/p1/index.html", "Common")
})
Attributes: {{ .Attributes }}|Type: {{ .Type }}|
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, "p1.md:7:9\": failed to parse Markdown attributes; you may need to quote the values")
files = strings.ReplaceAll(files, "RENDERFUNC", renderFunc)
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "text is already rendered, repeating it may cause infinite recursion")
<a href="{{ .Destination | safeURL }}">{{ .Text }}</a>`
}
- return hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ return hugolib.Test(t, files)
}
for _, withHook := range []bool{false, true} {
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/en/index.html", "0|February, 2020|Pages(1)1|January, 2020|Pages(1)")
b.AssertFileContent("public/fr/index.html", "0|février, 2020|Pages(1)1|janvier, 2020|Pages(1)")
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/en/index.html", `
ByTitle: alpha|émotion|zulu|
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
t.Log(b.LogString())
// No .File.TranslationBaseName on zero object etc. warnings.
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
t.Log(b.LogString())
// No .File.TranslationBaseName on zero object etc. warnings.
List.
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
t.Log(b.LogString())
// No .File.TranslationBaseName on zero object etc. warnings.
List.
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
t.Log(b.LogString())
// No .File.TranslationBaseName on zero object etc. warnings.
slug: custom-recipe-2
---
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelWarn,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptWarn())
t.Log(b.LogString())
b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 0)
{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
"Head Content: .",
{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html",
"Response Headers: map[Server:[Netlify] X-Frame-Options:[DENY]]",
t.Run("OK", func(t *testing.T) {
files := strings.ReplaceAll(filesTemplate, "TIMEOUT", "60s")
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- b.Build()
+ b := hugolib.Test(t, files)
for i := range numPages {
b.AssertFileContent(fmt.Sprintf("public/post/p%d/index.html", i), fmt.Sprintf("Content: Response for /post/p%d/.", i))
t.Run("Timeout", func(t *testing.T) {
files := strings.ReplaceAll(filesTemplate, "TIMEOUT", "100ms")
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
// This is hard to get stable on GitHub Actions, it sometimes succeeds due to timing issues.
if err != nil {
b.AssertLogContains("Got Err")
`
files = strings.ReplaceAll(files, "URL", srv.URL)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
// The per-request timeout of 200ms should fire well before the global 30s timeout.
b.AssertFileContent("public/index.html", "Err:")
`
files = strings.ReplaceAll(files, "URL", srv.URL)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "Content: Hello from remote.")
}
import (
"testing"
- "github.com/bep/logg"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
)
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
b.AssertLogContains("babel: Hugo Environment: production")
b.AssertFileContent("public/index.html", `var Car2 =`)
"strings"
"testing"
- "github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/htesting"
files := repl.Replace(postCSSIntegrationTestFiles)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- WorkingDir: tempDir,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+ cfg.WorkingDir = tempDir
+ }))
b.AssertFileContent("public/index.html", `
Styles RelPermalink: /foo/css/styles.css
c := qt.New(t)
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- TxtarString: strings.ReplaceAll(postCSSIntegrationTestFiles, "color: blue;", "@apply foo;"), // Syntax error
- }).BuildE()
+ b, err := hugolib.TestE(c, strings.ReplaceAll(postCSSIntegrationTestFiles, "color: blue;", "@apply foo;"), hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall())
ferrs := herrors.UnwrapFileErrors(err)
b.Assert(len(ferrs), qt.Equals, 2)
c := qt.New(t)
- _, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- TxtarString: postCSSIntegrationTestFiles,
- }).BuildE()
+ _, err := hugolib.TestE(c, postCSSIntegrationTestFiles, hugolib.TestOptOsFs())
ferrs := herrors.UnwrapFileErrors(err)
c.Assert(len(ferrs), qt.Equals, 1)
c := qt.New(t)
- _, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- TxtarString: strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`),
- }).BuildE()
+ _, err := hugolib.TestE(c, strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`), hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
ferrs := herrors.UnwrapFileErrors(err)
c.Assert(len(ferrs), qt.Equals, 2)
c.Assert(err.Error(), qt.Contains, "styles.css:4:3")
files := strings.ReplaceAll(postCSSIntegrationTestFiles, `@import "components/all.css";`, `@import "components/doesnotexist.css";`)
files = strings.ReplaceAll(files, `{{ $options := dict "inlineImports" true }}`, `{{ $options := dict "inlineImports" true "skipInlineImportsNotFound" true }}`)
- s := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- TxtarString: files,
- }).Build()
+ s := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
s.AssertFileContent("public/css/styles.css", `@import "components/doesnotexist.css";`)
}
files = strings.ReplaceAll(files, "useResourceCacheWhen = 'never'", " useResourceCacheWhen = 'always'")
}
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- TxtarString: files,
- WorkingDir: tempDir,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+ cfg.WorkingDir = tempDir
+ }))
b.AssertFileContent("public/index.html", `
Styles Content: Len: 770917
import (
"testing"
- "github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
CSS: {{ $css.Content | safeCSS }}|
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
b.AssertFileContent("public/index.html", "/*! tailwindcss v4.")
}
}
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- LogLevel: logg.LevelInfo,
- }).BuildE()
+ b, err := hugolib.TestE(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptInfo())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, "Can't resolve 'colors/red.css'")
`
c.Run("Basic", func(c *qt.C) {
- b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+ b := hugolib.Test(c, mainWithImport, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `abcd`)
})
c.Run("Edit Import", func(c *qt.C) {
- b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, Running: true, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+ b := hugolib.Test(c, mainWithImport, hugolib.TestOptRunning(), hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `abcd`)
b.EditFileReplaceFunc("assets/js/util1.js", func(s string) string { return strings.ReplaceAll(s, "abcd", "1234") }).Build()
})
c.Run("Edit Import Nested", func(c *qt.C) {
- b := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, Running: true, NeedsOsFS: true, TxtarString: mainWithImport}).Build()
+ b := hugolib.Test(c, mainWithImport, hugolib.TestOptRunning(), hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `efgh`)
b.EditFileReplaceFunc("assets/js/util2.js", func(s string) string { return strings.ReplaceAll(s, "efgh", "1234") }).Build()
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- TxtarString: files,
- Verbose: true,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+ cfg.Verbose = true
+ }))
b.AssertFileContent("public/js/main.js", `
greeting: "greeting configured in mod2"
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- NeedsNpmInstall: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs(), hugolib.TestOptWithNpmInstall())
b.AssertFileContent("public/js/main.js", `//# sourceMappingURL=main.js.map`)
b.AssertFileContent("public/js/main.js.map", `"version":3`, "! ns-hugo") // linked
c.Run("Import from main not found", func(c *qt.C) {
c.Parallel()
files := strings.Replace(filesTemplate, "import { hello1, hello2 }", "import { hello1, hello2, FOOBAR }", 1)
- b, err := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: files}).BuildE()
+ b, err := hugolib.TestE(c, files, hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `main.js:2:25": No matching export`)
})
c.Run("Import from import not found", func(c *qt.C) {
c.Parallel()
files := strings.Replace(filesTemplate, "import { hello3 } from './util2';", "import { hello3, FOOBAR } from './util2';", 1)
- b, err := hugolib.NewIntegrationTestBuilder(hugolib.IntegrationTestConfig{T: c, NeedsOsFS: true, TxtarString: files}).BuildE()
+ b, err := hugolib.TestE(c, files, hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `util1.js:4:17": No matching export in`)
})
files = strings.ReplaceAll(files, "IMPORT_SRC_DIR", importSrcDir)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- NeedsOsFS: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs())
expected := `
IMPORT_SRC_DIR:imp1/index.js
{{ $js.RelPermalink }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- NeedsOsFS: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/js/main.js", `
License util1
{{ $opts := dict "target" "es2020" "targetPath" "js/main.js" }}
{{ (resources.Get "ts/main.ts" | js.Build $opts).Publish }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- NeedsOsFS: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/js/main.js", "__decorateClass")
}
</script>
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(c, files)
b.Assert(err, qt.IsNotNil)
b.Assert(err, qt.ErrorMatches, "(?s).*legacy octal numbers.*line 1.*")
"strings"
"testing"
- "github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/htesting"
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: moo{color:#fff}`)
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
// Dart Sass does not follow regular CSS import, but they
// get pulled to the top.
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", "T1: #main {\n color: blue;\n}\n\n/* foo */")
}
source = 'foo'
target = 'assets/foo'
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `
@import "import-this-file.css";
@import "components/imports";
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: moo{color:#ccc}boo{color:green}zoo{color:pink}`)
}
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- LogLevel: logg.LevelInfo,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo())
b.AssertLogMatches(`Dart Sass: foo`)
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:1:0: bar`)
`
c.Run("error in main", func(c *qt.C) {
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1),
- NeedsOsFS: true,
- }).BuildE()
+ b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1), hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `main.scss:8:13":`)
})
c.Run("error in import", func(c *qt.C) {
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1),
- NeedsOsFS: true,
- }).BuildE()
+ b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1), hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `_foo.scss:2:10":`)
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover;font-family:Hugo's New Roman}p{color:blue;font-size:24px}b{color:green}`)
}
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover}p{color:blue;font-size:24px}b{color:green}`)
}
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- LogLevel: logg.LevelInfo,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptInfo())
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:3:0: color`)
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:4:0: color`)
Styles: {{ $r.RelPermalink }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
}
.bar2 {color: blue;}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- NeedsOsFS: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: moo{color:#fff}`)
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs())
// LibSass does not support regular CSS imports. There
// is an open bug about it that probably will never be resolved.
@import "components/imports";
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(c, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: moo{color:#ccc}boo{color:green}zoo{color:pink}`)
}
`
c.Run("error in main", func(c *qt.C) {
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1),
- NeedsOsFS: true,
- }).BuildE()
+ b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$maincolor: #eee;", "$maincolor #eee;", 1), hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, filepath.FromSlash(`themes/mytheme/assets/scss/main.scss:6:1": expected ':' after $maincolor in assignment statement`))
})
c.Run("error in import", func(c *qt.C) {
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: c,
- TxtarString: strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1),
- NeedsOsFS: true,
- }).BuildE()
+ b, err := hugolib.TestE(c, strings.Replace(filesTemplate, "$foocolor: #ccc;", "$foocolor #ccc;", 1), hugolib.TestOptOsFs())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `assets/scss/components/_foo.scss:2:1": expected ':' after $foocolor in assignment statement`)
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `T1: body body{background:url(images/hero.jpg) no-repeat center/cover;font-family:Hugo's New Roman}p{color:blue;font-size:var 24px}b{color:green}`)
}
Styles: {{ $r.RelPermalink }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
}
T1: {{ $r.Content }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- Running: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
b.AssertFileContent("public/index.html", `color: red`)
{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- Running: true,
- // LogLevel: logg.LevelTrace,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
b.AssertFileContent("public/index.html", `b.60a9f3bdc189ee8a857afd5b7e1b93ad1644de0873761a7c9bc84f781a821942.css`)
.bar2 {color: blue;}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- NeedsOsFS: true,
- TxtarString: files,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", ".foo1{color:red}.bar1{color:blue}.foo2{color:red}.bar2{color:blue}")
}
anigif: {{ $anigif.RelPermalink }}|{{ $anigif.Width }}|{{ $anigif.Height }}|{{ $anigif.MediaType }}|
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- Running: true,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
assertImages := func() {
b.AssertFileContent("public/index.html", `
Width: {{ $svg.Width }}
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- Running: true,
- }).BuildE()
+ b, err := hugolib.TestE(t, files, hugolib.TestOptOsFs(), hugolib.TestOptRunning())
b.Assert(err, qt.IsNotNil)
b.Assert(err.Error(), qt.Contains, `error calling Width: resource "/circle.svg" of media type "image/svg+xml" does not support this method: use reflect.IsImageResource, reflect.IsImageResourceProcessable, or reflect.IsImageResourceWithMeta to check if the resource supports this method before calling it`)
for range 3 {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- WorkingDir: workingDir,
- }).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs(), hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {
+ cfg.WorkingDir = workingDir
+ }))
b.AssertFileCount("resources/_gen/images", 6)
b.AssertFileCount("public/images", 1)
for range 4 {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Asc: [map[a:0 b:0] map[a:0 b:0] map[a:0 b:3] map[a:1 b:0] map[a:1 b:1] map[a:1 b:2] map[a:1 b:2] map[a:2 b:0] map[a:2 b:0] map[a:2 b:0] map[a:2 b:1] map[a:2 b:2] map[a:3 b:0] map[a:3 b:0] map[a:3 b:0] map[a:3 b:0] map[a:3 b:1] map[a:3 b:1] map[a:3 b:1] map[a:3 b:3]]
for range 4 {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", "[a <nil> c <nil>]")
import (
"testing"
- "github.com/bep/logg"
"github.com/gohugoio/hugo/hugolib"
)
{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- LogLevel: logg.LevelInfo,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptInfo())
b.AssertLogContains("timer: name foo count 5 duration")
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `
START:|hugo.toml|myproject.txt|:END:
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/index.html", `
OK
func TestReadFile(t *testing.T) {
t.Parallel()
- b := newFileTestBuilder(t).Build()
+ b := newFileTestBuilder(t)
// helpers.PrintFs(b.H.PathSpec.BaseFs.Work, "", _os.Stdout)
t.Parallel()
c := qt.New(t)
- b := newFileTestBuilder(t).Build()
+ b := newFileTestBuilder(t)
ns := os.New(b.H.Deps)
for _, test := range []struct {
func TestStat(t *testing.T) {
t.Parallel()
- b := newFileTestBuilder(t).Build()
+ b := newFileTestBuilder(t)
ns := os.New(b.H.Deps)
for _, test := range []struct {
f2-content
`
- return hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- WorkingDir: "/mywork",
- },
- )
+ return hugolib.Test(t, files, hugolib.TestOptWithConfig(func(c *hugolib.IntegrationTestConfig) {
+ c.WorkingDir = "/mywork"
+ }))
}
for range 1 {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `
Heading OK.
{{ partial "foo.html" . }}
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, "maximum template call stack size exceeded")
{{ partialCached "foo.html" . }}
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, `error calling partialCached: circular call stack detected in partial`)
`
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- }).BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err, qt.IsNotNil)
}
func TestTimeLocation(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
loc, _ := gtime.LoadLocation("America/Antigua")
ns := time.New(htime.NewTimeFormatter(golocales.New("en")), loc, b.H.Deps)
func TestFormat(t *testing.T) {
c := qt.New(t)
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
c.Run("UTC", func(c *qt.C) {
c.Parallel()
func TestDuration(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, b.H.Deps)
func TestIn(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, b.H.Deps)
var timeZoneNames []string = []string{"America/New_York", "Europe/Oslo", "Australia/Sydney", "UTC", "Local"}
func BenchmarkInWithCaching(b *testing.B) {
- bb := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: b},
- ).Build()
+ bb := hugolib.Test(b, "")
ns := time.New(htime.NewTimeFormatter(golocales.New("en")), gtime.UTC, bb.H.Deps)
---
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
d := b.H.Sites[0].Deps
}
files += fmt.Sprintf("-- layouts/single.html --\n%s\n", strings.Join(templates, "\n"))
- b = hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- ).Build()
+ b = hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/blog/hugo-rocks/index.html", expected...)
}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/p1/index.html", "MAIN /_default/single.html")
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: true,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files, hugolib.TestOptOsFs())
b.AssertFileContent("public/p1/index.html", `
continue:1345:END:
{{ define "main" }}{{ .Title }}{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/s1/p1/index.html", `S1P1`)
b.AssertFileContent("public/s2/p1/index.html", `S2P1`)
{{ end }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
- b.Build()
+ b := hugolib.Test(t, files)
b.AssertFileContent("public/index.html", `key = value`)
})
files := strings.ReplaceAll(filesTemplate, "SECURITYCONFIG", "")
- b, err := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- ).BuildE()
+ b, err := hugolib.TestE(t, files)
// This used to fail, but not in >= Hugo 0.121.0.
b.Assert(err, qt.IsNil)
func TestRemarshal(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
c := qt.New(t)
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
-- layouts/home.html --
{{ highlight "a" "b" 0 }}
`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- },
- )
-
- _, err := b.BuildE()
+ b, err := hugolib.TestE(t, files)
b.Assert(err.Error(), qt.Contains, "error calling highlight: invalid Highlight option: 0")
}
func TestEmojify(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
func TestHighlight(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
func TestHTMLEscape(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
func TestHTMLUnescape(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
func TestMarkdownify(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
// Issue #3040
func TestMarkdownifyBlocksOfText(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
func TestPlainify(t *testing.T) {
t.Parallel()
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
}
func TestUnmarshal(t *testing.T) {
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t},
- ).Build()
+ b := hugolib.Test(t, "")
ns := transform.New(b.H.Deps)
}
func BenchmarkUnmarshalString(b *testing.B) {
- bb := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: b},
- ).Build()
+ bb := hugolib.Test(b, "")
ns := transform.New(bb.H.Deps)
}
func BenchmarkUnmarshalResource(b *testing.B) {
- bb := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: b},
- ).Build()
+ bb := hugolib.Test(b, "")
ns := transform.New(bb.H.Deps)