aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/hugo_sites_build_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2019-08-10 21:05:17 +0200
committerBjørn Erik Pedersen <[email protected]>2019-08-12 13:26:32 +0200
commit9e571827055dedb46b78c5db3d17d6913f14870b (patch)
treef5f0108afe0c9385ff6dc27664943d9f719f57ad /hugolib/hugo_sites_build_test.go
parent6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff)
downloadhugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz
hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip
tests: Convert from testify to quicktest
Diffstat (limited to 'hugolib/hugo_sites_build_test.go')
-rw-r--r--hugolib/hugo_sites_build_test.go267
1 files changed, 133 insertions, 134 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index 15e4920f0..1a690cdd9 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -8,6 +8,7 @@ import (
"path/filepath"
"time"
+ qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/resources/page"
"github.com/fortytw2/leaktest"
@@ -15,7 +16,6 @@ import (
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/afero"
- "github.com/stretchr/testify/require"
)
func TestMultiSitesMainLangInRoot(t *testing.T) {
@@ -26,7 +26,7 @@ func TestMultiSitesMainLangInRoot(t *testing.T) {
}
func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
- assert := require.New(t)
+ c := qt.New(t)
siteConfig := map[string]interface{}{
"DefaultContentLanguage": "fr",
@@ -49,29 +49,28 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
b.Build(BuildCfg{})
sites := b.H.Sites
-
- require.Len(t, sites, 4)
+ c.Assert(len(sites), qt.Equals, 4)
enSite := sites[0]
frSite := sites[1]
- assert.Equal("/en", enSite.Info.LanguagePrefix)
+ c.Assert(enSite.Info.LanguagePrefix, qt.Equals, "/en")
if defaultInSubDir {
- assert.Equal("/fr", frSite.Info.LanguagePrefix)
+ c.Assert(frSite.Info.LanguagePrefix, qt.Equals, "/fr")
} else {
- assert.Equal("", frSite.Info.LanguagePrefix)
+ c.Assert(frSite.Info.LanguagePrefix, qt.Equals, "")
}
- assert.Equal("/blog/en/foo", enSite.PathSpec.RelURL("foo", true))
+ c.Assert(enSite.PathSpec.RelURL("foo", true), qt.Equals, "/blog/en/foo")
doc1en := enSite.RegularPages()[0]
doc1fr := frSite.RegularPages()[0]
enPerm := doc1en.Permalink()
enRelPerm := doc1en.RelPermalink()
- assert.Equal("http://example.com/blog/en/sect/doc1-slug/", enPerm)
- assert.Equal("/blog/en/sect/doc1-slug/", enRelPerm)
+ c.Assert(enPerm, qt.Equals, "http://example.com/blog/en/sect/doc1-slug/")
+ c.Assert(enRelPerm, qt.Equals, "/blog/en/sect/doc1-slug/")
frPerm := doc1fr.Permalink()
frRelPerm := doc1fr.RelPermalink()
@@ -80,15 +79,15 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
b.AssertFileContent("public/en/sect/doc1-slug/index.html", "Single", "Hello")
if defaultInSubDir {
- assert.Equal("http://example.com/blog/fr/sect/doc1/", frPerm)
- assert.Equal("/blog/fr/sect/doc1/", frRelPerm)
+ c.Assert(frPerm, qt.Equals, "http://example.com/blog/fr/sect/doc1/")
+ c.Assert(frRelPerm, qt.Equals, "/blog/fr/sect/doc1/")
// should have a redirect on top level.
b.AssertFileContent("public/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog/fr" />`)
} else {
// Main language in root
- assert.Equal("http://example.com/blog/sect/doc1/", frPerm)
- assert.Equal("/blog/sect/doc1/", frRelPerm)
+ c.Assert(frPerm, qt.Equals, "http://example.com/blog/sect/doc1/")
+ c.Assert(frRelPerm, qt.Equals, "/blog/sect/doc1/")
// should have redirect back to root
b.AssertFileContent("public/fr/index.html", `<meta http-equiv="refresh" content="0; url=http://example.com/blog" />`)
@@ -154,7 +153,7 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
func TestMultiSitesWithTwoLanguages(t *testing.T) {
t.Parallel()
- assert := require.New(t)
+ c := qt.New(t)
b := newTestSitesBuilder(t).WithConfigFile("toml", `
defaultContentLanguage = "nn"
@@ -179,23 +178,23 @@ p1 = "p1en"
b.Build(BuildCfg{SkipRender: true})
sites := b.H.Sites
- assert.Len(sites, 2)
+ c.Assert(len(sites), qt.Equals, 2)
nnSite := sites[0]
nnHome := nnSite.getPage(page.KindHome)
- assert.Len(nnHome.AllTranslations(), 2)
- assert.Len(nnHome.Translations(), 1)
- assert.True(nnHome.IsTranslated())
+ c.Assert(len(nnHome.AllTranslations()), qt.Equals, 2)
+ c.Assert(len(nnHome.Translations()), qt.Equals, 1)
+ c.Assert(nnHome.IsTranslated(), qt.Equals, true)
enHome := sites[1].getPage(page.KindHome)
p1, err := enHome.Param("p1")
- assert.NoError(err)
- assert.Equal("p1en", p1)
+ c.Assert(err, qt.IsNil)
+ c.Assert(p1, qt.Equals, "p1en")
p1, err = nnHome.Param("p1")
- assert.NoError(err)
- assert.Equal("p1nn", p1)
+ c.Assert(err, qt.IsNil)
+ c.Assert(p1, qt.Equals, "p1nn")
}
func TestMultiSitesBuild(t *testing.T) {
@@ -217,38 +216,38 @@ func TestMultiSitesBuild(t *testing.T) {
}
func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
- assert := require.New(t)
+ c := qt.New(t)
b := newMultiSiteTestBuilder(t, configSuffix, configTemplate, nil)
b.CreateSites()
sites := b.H.Sites
- assert.Equal(4, len(sites))
+ c.Assert(len(sites), qt.Equals, 4)
b.Build(BuildCfg{})
// Check site config
for _, s := range sites {
- require.True(t, s.Info.defaultContentLanguageInSubdir, s.Info.title)
- require.NotNil(t, s.disabledKinds)
+ c.Assert(s.Info.defaultContentLanguageInSubdir, qt.Equals, true)
+ c.Assert(s.disabledKinds, qt.Not(qt.IsNil))
}
gp1 := b.H.GetContentPage(filepath.FromSlash("content/sect/doc1.en.md"))
- require.NotNil(t, gp1)
- require.Equal(t, "doc1", gp1.Title())
+ c.Assert(gp1, qt.Not(qt.IsNil))
+ c.Assert(gp1.Title(), qt.Equals, "doc1")
gp2 := b.H.GetContentPage(filepath.FromSlash("content/dummysect/notfound.md"))
- require.Nil(t, gp2)
+ c.Assert(gp2, qt.IsNil)
enSite := sites[0]
enSiteHome := enSite.getPage(page.KindHome)
- require.True(t, enSiteHome.IsTranslated())
+ c.Assert(enSiteHome.IsTranslated(), qt.Equals, true)
- require.Equal(t, "en", enSite.language.Lang)
+ c.Assert(enSite.language.Lang, qt.Equals, "en")
//dumpPages(enSite.RegularPages()...)
- assert.Equal(5, len(enSite.RegularPages()))
- assert.Equal(32, len(enSite.AllPages()))
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 5)
+ c.Assert(len(enSite.AllPages()), qt.Equals, 32)
// Check 404s
b.AssertFileContent("public/en/404.html", "404|en|404 Page not found")
@@ -264,33 +263,33 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
doc2 := enSite.RegularPages()[1]
doc3 := enSite.RegularPages()[2]
- require.Equal(t, doc2.Prev(), doc3, "doc3 should follow doc2, in .PrevPage")
+ c.Assert(doc3, qt.Equals, doc2.Prev())
doc1en := enSite.RegularPages()[0]
doc1fr := doc1en.Translations()[0]
b.AssertFileContent("public/fr/sect/doc1/index.html", "Permalink: http://example.com/blog/fr/sect/doc1/")
- require.Equal(t, doc1en.Translations()[0], doc1fr, "doc1-en should have doc1-fr as translation")
- require.Equal(t, doc1fr.Translations()[0], doc1en, "doc1-fr should have doc1-en as translation")
- require.Equal(t, "fr", doc1fr.Language().Lang)
+ c.Assert(doc1fr, qt.Equals, doc1en.Translations()[0])
+ c.Assert(doc1en, qt.Equals, doc1fr.Translations()[0])
+ c.Assert(doc1fr.Language().Lang, qt.Equals, "fr")
doc4 := enSite.AllPages()[4]
- require.Len(t, doc4.Translations(), 0, "found translations for doc4")
+ c.Assert(len(doc4.Translations()), qt.Equals, 0)
// Taxonomies and their URLs
- require.Len(t, enSite.Taxonomies, 1, "should have 1 taxonomy")
+ c.Assert(len(enSite.Taxonomies), qt.Equals, 1)
tags := enSite.Taxonomies["tags"]
- require.Len(t, tags, 2, "should have 2 different tags")
- require.Equal(t, tags["tag1"][0].Page, doc1en, "first tag1 page should be doc1")
+ c.Assert(len(tags), qt.Equals, 2)
+ c.Assert(doc1en, qt.Equals, tags["tag1"][0].Page)
frSite := sites[1]
- require.Equal(t, "fr", frSite.language.Lang)
- require.Len(t, frSite.RegularPages(), 4, "should have 3 pages")
- require.Len(t, frSite.AllPages(), 32, "should have 32 total pages (including translations and nodes)")
+ c.Assert(frSite.language.Lang, qt.Equals, "fr")
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 4)
+ c.Assert(len(frSite.AllPages()), qt.Equals, 32)
for _, frenchPage := range frSite.RegularPages() {
p := frenchPage
- require.Equal(t, "fr", p.Language().Lang)
+ c.Assert(p.Language().Lang, qt.Equals, "fr")
}
// See https://github.com/gohugoio/hugo/issues/4285
@@ -302,10 +301,10 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
getPageDoc1EnBase := enSite.getPage(page.KindPage, "sect/doc1")
getPageDoc1Fr := frSite.getPage(page.KindPage, filepath.ToSlash(doc1fr.File().Path()))
getPageDoc1FrBase := frSite.getPage(page.KindPage, "sect/doc1")
- require.Equal(t, doc1en, getPageDoc1En)
- require.Equal(t, doc1fr, getPageDoc1Fr)
- require.Equal(t, doc1en, getPageDoc1EnBase)
- require.Equal(t, doc1fr, getPageDoc1FrBase)
+ c.Assert(getPageDoc1En, qt.Equals, doc1en)
+ c.Assert(getPageDoc1Fr, qt.Equals, doc1fr)
+ c.Assert(getPageDoc1EnBase, qt.Equals, doc1en)
+ c.Assert(getPageDoc1FrBase, qt.Equals, doc1fr)
// Check redirect to main language, French
b.AssertFileContent("public/index.html", "0; url=http://example.com/blog/fr")
@@ -320,35 +319,35 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
// Check node translations
homeEn := enSite.getPage(page.KindHome)
- require.NotNil(t, homeEn)
- require.Len(t, homeEn.Translations(), 3)
- require.Equal(t, "fr", homeEn.Translations()[0].Language().Lang)
- require.Equal(t, "nn", homeEn.Translations()[1].Language().Lang)
- require.Equal(t, "På nynorsk", homeEn.Translations()[1].Title())
- require.Equal(t, "nb", homeEn.Translations()[2].Language().Lang)
- require.Equal(t, "På bokmål", homeEn.Translations()[2].Title(), configSuffix)
- require.Equal(t, "Bokmål", homeEn.Translations()[2].Language().LanguageName, configSuffix)
+ c.Assert(homeEn, qt.Not(qt.IsNil))
+ c.Assert(len(homeEn.Translations()), qt.Equals, 3)
+ c.Assert(homeEn.Translations()[0].Language().Lang, qt.Equals, "fr")
+ c.Assert(homeEn.Translations()[1].Language().Lang, qt.Equals, "nn")
+ c.Assert(homeEn.Translations()[1].Title(), qt.Equals, "På nynorsk")
+ c.Assert(homeEn.Translations()[2].Language().Lang, qt.Equals, "nb")
+ c.Assert(homeEn.Translations()[2].Title(), qt.Equals, "På bokmål")
+ c.Assert(homeEn.Translations()[2].Language().LanguageName, qt.Equals, "Bokmål")
sectFr := frSite.getPage(page.KindSection, "sect")
- require.NotNil(t, sectFr)
+ c.Assert(sectFr, qt.Not(qt.IsNil))
- require.Equal(t, "fr", sectFr.Language().Lang)
- require.Len(t, sectFr.Translations(), 1)
- require.Equal(t, "en", sectFr.Translations()[0].Language().Lang)
- require.Equal(t, "Sects", sectFr.Translations()[0].Title())
+ c.Assert(sectFr.Language().Lang, qt.Equals, "fr")
+ c.Assert(len(sectFr.Translations()), qt.Equals, 1)
+ c.Assert(sectFr.Translations()[0].Language().Lang, qt.Equals, "en")
+ c.Assert(sectFr.Translations()[0].Title(), qt.Equals, "Sects")
nnSite := sites[2]
- require.Equal(t, "nn", nnSite.language.Lang)
+ c.Assert(nnSite.language.Lang, qt.Equals, "nn")
taxNn := nnSite.getPage(page.KindTaxonomyTerm, "lag")
- require.NotNil(t, taxNn)
- require.Len(t, taxNn.Translations(), 1)
- require.Equal(t, "nb", taxNn.Translations()[0].Language().Lang)
+ c.Assert(taxNn, qt.Not(qt.IsNil))
+ c.Assert(len(taxNn.Translations()), qt.Equals, 1)
+ c.Assert(taxNn.Translations()[0].Language().Lang, qt.Equals, "nb")
taxTermNn := nnSite.getPage(page.KindTaxonomy, "lag", "sogndal")
- require.NotNil(t, taxTermNn)
- require.Equal(t, taxTermNn, nnSite.getPage(page.KindTaxonomy, "LAG", "SOGNDAL"))
- require.Len(t, taxTermNn.Translations(), 1)
- require.Equal(t, "nb", taxTermNn.Translations()[0].Language().Lang)
+ c.Assert(taxTermNn, qt.Not(qt.IsNil))
+ c.Assert(nnSite.getPage(page.KindTaxonomy, "LAG", "SOGNDAL"), qt.Equals, taxTermNn)
+ c.Assert(len(taxTermNn.Translations()), qt.Equals, 1)
+ c.Assert(taxTermNn.Translations()[0].Language().Lang, qt.Equals, "nb")
// Check sitemap(s)
b.AssertFileContent("public/sitemap.xml",
@@ -360,54 +359,54 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
// Check taxonomies
enTags := enSite.Taxonomies["tags"]
frTags := frSite.Taxonomies["plaques"]
- require.Len(t, enTags, 2, fmt.Sprintf("Tags in en: %v", enTags))
- require.Len(t, frTags, 2, fmt.Sprintf("Tags in fr: %v", frTags))
- require.NotNil(t, enTags["tag1"])
- require.NotNil(t, frTags["FRtag1"])
+ c.Assert(len(enTags), qt.Equals, 2, qt.Commentf("Tags in en: %v", enTags))
+ c.Assert(len(frTags), qt.Equals, 2, qt.Commentf("Tags in fr: %v", frTags))
+ c.Assert(enTags["tag1"], qt.Not(qt.IsNil))
+ c.Assert(frTags["FRtag1"], qt.Not(qt.IsNil))
b.AssertFileContent("public/fr/plaques/FRtag1/index.html", "FRtag1|Bonjour|http://example.com/blog/fr/plaques/FRtag1/")
// Check Blackfriday config
- require.True(t, strings.Contains(content(doc1fr), "&laquo;"), content(doc1fr))
- require.False(t, strings.Contains(content(doc1en), "&laquo;"), content(doc1en))
- require.True(t, strings.Contains(content(doc1en), "&ldquo;"), content(doc1en))
+ c.Assert(strings.Contains(content(doc1fr), "&laquo;"), qt.Equals, true)
+ c.Assert(strings.Contains(content(doc1en), "&laquo;"), qt.Equals, false)
+ c.Assert(strings.Contains(content(doc1en), "&ldquo;"), qt.Equals, true)
// en and nn have custom site menus
- require.Len(t, frSite.Menus(), 0, "fr: "+configSuffix)
- require.Len(t, enSite.Menus(), 1, "en: "+configSuffix)
- require.Len(t, nnSite.Menus(), 1, "nn: "+configSuffix)
+ c.Assert(len(frSite.Menus()), qt.Equals, 0)
+ c.Assert(len(enSite.Menus()), qt.Equals, 1)
+ c.Assert(len(nnSite.Menus()), qt.Equals, 1)
- require.Equal(t, "Home", enSite.Menus()["main"].ByName()[0].Name)
- require.Equal(t, "Heim", nnSite.Menus()["main"].ByName()[0].Name)
+ c.Assert(enSite.Menus()["main"].ByName()[0].Name, qt.Equals, "Home")
+ c.Assert(nnSite.Menus()["main"].ByName()[0].Name, qt.Equals, "Heim")
// Issue #3108
prevPage := enSite.RegularPages()[0].Prev()
- require.NotNil(t, prevPage)
- require.Equal(t, page.KindPage, prevPage.Kind())
+ c.Assert(prevPage, qt.Not(qt.IsNil))
+ c.Assert(prevPage.Kind(), qt.Equals, page.KindPage)
for {
if prevPage == nil {
break
}
- require.Equal(t, page.KindPage, prevPage.Kind())
+ c.Assert(prevPage.Kind(), qt.Equals, page.KindPage)
prevPage = prevPage.Prev()
}
// Check bundles
b.AssertFileContent("public/fr/bundles/b1/index.html", "RelPermalink: /blog/fr/bundles/b1/|")
bundleFr := frSite.getPage(page.KindPage, "bundles/b1/index.md")
- require.NotNil(t, bundleFr)
- require.Equal(t, 1, len(bundleFr.Resources()))
+ c.Assert(bundleFr, qt.Not(qt.IsNil))
+ c.Assert(len(bundleFr.Resources()), qt.Equals, 1)
logoFr := bundleFr.Resources().GetMatch("logo*")
- require.NotNil(t, logoFr)
+ c.Assert(logoFr, qt.Not(qt.IsNil))
b.AssertFileContent("public/fr/bundles/b1/index.html", "Resources: image/png: /blog/fr/bundles/b1/logo.png")
b.AssertFileContent("public/fr/bundles/b1/logo.png", "PNG Data")
bundleEn := enSite.getPage(page.KindPage, "bundles/b1/index.en.md")
- require.NotNil(t, bundleEn)
+ c.Assert(bundleEn, qt.Not(qt.IsNil))
b.AssertFileContent("public/en/bundles/b1/index.html", "RelPermalink: /blog/en/bundles/b1/|")
- require.Equal(t, 1, len(bundleEn.Resources()))
+ c.Assert(len(bundleEn.Resources()), qt.Equals, 1)
logoEn := bundleEn.Resources().GetMatch("logo*")
- require.NotNil(t, logoEn)
+ c.Assert(logoEn, qt.Not(qt.IsNil))
b.AssertFileContent("public/en/bundles/b1/index.html", "Resources: image/png: /blog/en/bundles/b1/logo.png")
b.AssertFileContent("public/en/bundles/b1/logo.png", "PNG Data")
@@ -420,7 +419,7 @@ func TestMultiSitesRebuild(t *testing.T) {
defer leaktest.CheckTimeout(t, 10*time.Second)()
}
- assert := require.New(t)
+ c := qt.New(t)
b := newMultiSiteTestDefaultBuilder(t).Running().CreateSites().Build(BuildCfg{})
@@ -432,8 +431,8 @@ func TestMultiSitesRebuild(t *testing.T) {
enSite := sites[0]
frSite := sites[1]
- assert.Len(enSite.RegularPages(), 5)
- assert.Len(frSite.RegularPages(), 4)
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 5)
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 4)
// Verify translations
b.AssertFileContent("public/en/sect/doc1-slug/index.html", "Hello")
@@ -444,8 +443,8 @@ func TestMultiSitesRebuild(t *testing.T) {
b.AssertFileContent("public/en/sect/doc1-slug/index.html", "Single", "Shortcode: Hello")
homeEn := enSite.getPage(page.KindHome)
- require.NotNil(t, homeEn)
- assert.Len(homeEn.Translations(), 3)
+ c.Assert(homeEn, qt.Not(qt.IsNil))
+ c.Assert(len(homeEn.Translations()), qt.Equals, 3)
contentFs := b.H.Fs.Source
@@ -467,7 +466,7 @@ func TestMultiSitesRebuild(t *testing.T) {
},
[]fsnotify.Event{{Name: filepath.FromSlash("content/sect/doc2.en.md"), Op: fsnotify.Remove}},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 4, "1 en removed")
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 4, qt.Commentf("1 en removed"))
},
},
@@ -483,15 +482,15 @@ func TestMultiSitesRebuild(t *testing.T) {
{Name: filepath.FromSlash("content/new1.fr.md"), Op: fsnotify.Create},
},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6)
- assert.Len(enSite.AllPages(), 34)
- assert.Len(frSite.RegularPages(), 5)
- require.Equal(t, "new_fr_1", frSite.RegularPages()[3].Title())
- require.Equal(t, "new_en_2", enSite.RegularPages()[0].Title())
- require.Equal(t, "new_en_1", enSite.RegularPages()[1].Title())
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
+ c.Assert(len(enSite.AllPages()), qt.Equals, 34)
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 5)
+ c.Assert(frSite.RegularPages()[3].Title(), qt.Equals, "new_fr_1")
+ c.Assert(enSite.RegularPages()[0].Title(), qt.Equals, "new_en_2")
+ c.Assert(enSite.RegularPages()[1].Title(), qt.Equals, "new_en_1")
rendered := readDestination(t, fs, "public/en/new1/index.html")
- require.True(t, strings.Contains(rendered, "new_en_1"), rendered)
+ c.Assert(strings.Contains(rendered, "new_en_1"), qt.Equals, true)
},
},
{
@@ -503,9 +502,9 @@ func TestMultiSitesRebuild(t *testing.T) {
},
[]fsnotify.Event{{Name: filepath.FromSlash("content/sect/doc1.en.md"), Op: fsnotify.Write}},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6)
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
doc1 := readDestination(t, fs, "public/en/sect/doc1-slug/index.html")
- require.True(t, strings.Contains(doc1, "CHANGED"), doc1)
+ c.Assert(strings.Contains(doc1, "CHANGED"), qt.Equals, true)
},
},
@@ -521,10 +520,10 @@ func TestMultiSitesRebuild(t *testing.T) {
{Name: filepath.FromSlash("content/new1.en.md"), Op: fsnotify.Rename},
},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6, "Rename")
- require.Equal(t, "new_en_1", enSite.RegularPages()[1].Title())
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6, qt.Commentf("Rename"))
+ c.Assert(enSite.RegularPages()[1].Title(), qt.Equals, "new_en_1")
rendered := readDestination(t, fs, "public/en/new1renamed/index.html")
- require.True(t, strings.Contains(rendered, "new_en_1"), rendered)
+ c.Assert(rendered, qt.Contains, "new_en_1")
}},
{
// Change a template
@@ -536,11 +535,11 @@ func TestMultiSitesRebuild(t *testing.T) {
},
[]fsnotify.Event{{Name: filepath.FromSlash("layouts/_default/single.html"), Op: fsnotify.Write}},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6)
- assert.Len(enSite.AllPages(), 34)
- assert.Len(frSite.RegularPages(), 5)
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
+ c.Assert(len(enSite.AllPages()), qt.Equals, 34)
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 5)
doc1 := readDestination(t, fs, "public/en/sect/doc1-slug/index.html")
- require.True(t, strings.Contains(doc1, "Template Changed"), doc1)
+ c.Assert(strings.Contains(doc1, "Template Changed"), qt.Equals, true)
},
},
{
@@ -553,18 +552,18 @@ func TestMultiSitesRebuild(t *testing.T) {
},
[]fsnotify.Event{{Name: filepath.FromSlash("i18n/fr.yaml"), Op: fsnotify.Write}},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6)
- assert.Len(enSite.AllPages(), 34)
- assert.Len(frSite.RegularPages(), 5)
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
+ c.Assert(len(enSite.AllPages()), qt.Equals, 34)
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 5)
docEn := readDestination(t, fs, "public/en/sect/doc1-slug/index.html")
- require.True(t, strings.Contains(docEn, "Hello"), "No Hello")
+ c.Assert(strings.Contains(docEn, "Hello"), qt.Equals, true)
docFr := readDestination(t, fs, "public/fr/sect/doc1/index.html")
- require.True(t, strings.Contains(docFr, "Salut"), "No Salut")
+ c.Assert(strings.Contains(docFr, "Salut"), qt.Equals, true)
homeEn := enSite.getPage(page.KindHome)
- require.NotNil(t, homeEn)
- assert.Len(homeEn.Translations(), 3)
- require.Equal(t, "fr", homeEn.Translations()[0].Language().Lang)
+ c.Assert(homeEn, qt.Not(qt.IsNil))
+ c.Assert(len(homeEn.Translations()), qt.Equals, 3)
+ c.Assert(homeEn.Translations()[0].Language().Lang, qt.Equals, "fr")
},
},
@@ -577,9 +576,9 @@ func TestMultiSitesRebuild(t *testing.T) {
{Name: filepath.FromSlash("layouts/shortcodes/shortcode.html"), Op: fsnotify.Write},
},
func(t *testing.T) {
- assert.Len(enSite.RegularPages(), 6)
- assert.Len(enSite.AllPages(), 34)
- assert.Len(frSite.RegularPages(), 5)
+ c.Assert(len(enSite.RegularPages()), qt.Equals, 6)
+ c.Assert(len(enSite.AllPages()), qt.Equals, 34)
+ c.Assert(len(frSite.RegularPages()), qt.Equals, 5)
b.AssertFileContent("public/fr/sect/doc1/index.html", "Single", "Modified Shortcode: Salut")
b.AssertFileContent("public/en/sect/doc1-slug/index.html", "Single", "Modified Shortcode: Hello")
},
@@ -781,24 +780,24 @@ categories: ["mycat"]
} {
t.Run(path, func(t *testing.T) {
- assert := require.New(t)
+ c := qt.New(t)
s1, _ := b.H.Sites[0].getPageNew(nil, path)
s2, _ := b.H.Sites[1].getPageNew(nil, path)
- assert.NotNil(s1)
- assert.NotNil(s2)
+ c.Assert(s1, qt.Not(qt.IsNil))
+ c.Assert(s2, qt.Not(qt.IsNil))
- assert.Equal(1, len(s1.Translations()))
- assert.Equal(1, len(s2.Translations()))
- assert.Equal(s2, s1.Translations()[0])
- assert.Equal(s1, s2.Translations()[0])
+ c.Assert(len(s1.Translations()), qt.Equals, 1)
+ c.Assert(len(s2.Translations()), qt.Equals, 1)
+ c.Assert(s1.Translations()[0], qt.Equals, s2)
+ c.Assert(s2.Translations()[0], qt.Equals, s1)
m1 := s1.Translations().MergeByLanguage(s2.Translations())
m2 := s2.Translations().MergeByLanguage(s1.Translations())
- assert.Equal(1, len(m1))
- assert.Equal(1, len(m2))
+ c.Assert(len(m1), qt.Equals, 1)
+ c.Assert(len(m2), qt.Equals, 1)
})
}