mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03:00
tests: Convert from testify to quicktest
This commit is contained in:
parent
6027ee1108
commit
9e57182705
195 changed files with 3919 additions and 3693 deletions
|
@ -24,10 +24,9 @@ import (
|
|||
|
||||
"github.com/gohugoio/hugo/helpers"
|
||||
|
||||
qt "github.com/frankban/quicktest"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/resources/page"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -145,6 +144,7 @@ func TestLastChange(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
cfg, fs := newTestCfg()
|
||||
c := qt.New(t)
|
||||
|
||||
writeSource(t, fs, filepath.Join("content", "sect/doc1.md"), "---\ntitle: doc1\nweight: 1\ndate: 2014-05-29\n---\n# doc1\n*some content*")
|
||||
writeSource(t, fs, filepath.Join("content", "sect/doc2.md"), "---\ntitle: doc2\nweight: 2\ndate: 2015-05-29\n---\n# doc2\n*some content*")
|
||||
|
@ -154,8 +154,8 @@ func TestLastChange(t *testing.T) {
|
|||
|
||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
|
||||
|
||||
require.False(t, s.Info.LastChange().IsZero(), "Site.LastChange is zero")
|
||||
require.Equal(t, 2017, s.Info.LastChange().Year(), "Site.LastChange should be set to the page with latest Lastmod (year 2017)")
|
||||
c.Assert(s.Info.LastChange().IsZero(), qt.Equals, false)
|
||||
c.Assert(s.Info.LastChange().Year(), qt.Equals, 2017)
|
||||
}
|
||||
|
||||
// Issue #_index
|
||||
|
@ -163,12 +163,13 @@ func TestPageWithUnderScoreIndexInFilename(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
cfg, fs := newTestCfg()
|
||||
c := qt.New(t)
|
||||
|
||||
writeSource(t, fs, filepath.Join("content", "sect/my_index_file.md"), "---\ntitle: doc1\nweight: 1\ndate: 2014-05-29\n---\n# doc1\n*some content*")
|
||||
|
||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
|
||||
|
||||
require.Len(t, s.RegularPages(), 1)
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 1)
|
||||
|
||||
}
|
||||
|
||||
|
@ -184,6 +185,8 @@ func TestCrossrefs(t *testing.T) {
|
|||
|
||||
func doTestCrossrefs(t *testing.T, relative, uglyURLs bool) {
|
||||
|
||||
c := qt.New(t)
|
||||
|
||||
baseURL := "http://foo/bar"
|
||||
|
||||
var refShortcode string
|
||||
|
@ -253,9 +256,9 @@ THE END.`, refShortcode),
|
|||
WithTemplate: createWithTemplateFromNameValues("_default/single.html", "{{.Content}}")},
|
||||
BuildCfg{})
|
||||
|
||||
require.Len(t, s.RegularPages(), 4)
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 4)
|
||||
|
||||
th := testHelper{s.Cfg, s.Fs, t}
|
||||
th := newTestHelper(s.Cfg, s.Fs, t)
|
||||
|
||||
tests := []struct {
|
||||
doc string
|
||||
|
@ -286,6 +289,7 @@ func TestShouldAlwaysHaveUglyURLs(t *testing.T) {
|
|||
func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
||||
|
||||
cfg, fs := newTestCfg()
|
||||
c := qt.New(t)
|
||||
|
||||
cfg.Set("verbose", true)
|
||||
cfg.Set("baseURL", "http://auth/bub")
|
||||
|
@ -333,7 +337,7 @@ func doTestShouldAlwaysHaveUglyURLs(t *testing.T, uglyURLs bool) {
|
|||
}
|
||||
|
||||
for _, p := range s.RegularPages() {
|
||||
assert.False(t, p.IsHome())
|
||||
c.Assert(p.IsHome(), qt.Equals, false)
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -355,7 +359,7 @@ func TestShouldNotWriteZeroLengthFilesToDestination(t *testing.T) {
|
|||
writeSource(t, fs, filepath.Join("layouts", "_default/list.html"), "")
|
||||
|
||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
|
||||
th := testHelper{s.Cfg, s.Fs, t}
|
||||
th := newTestHelper(s.Cfg, s.Fs, t)
|
||||
|
||||
th.assertFileNotExist(filepath.Join("public", "index.html"))
|
||||
}
|
||||
|
@ -378,6 +382,7 @@ func TestSectionNaming(t *testing.T) {
|
|||
}
|
||||
|
||||
func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
||||
c := qt.New(t)
|
||||
|
||||
var expectedPathSuffix string
|
||||
|
||||
|
@ -412,10 +417,10 @@ func doTestSectionNaming(t *testing.T, canonify, uglify, pluralize bool) {
|
|||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
|
||||
|
||||
mainSections, err := s.Info.Param("mainSections")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []string{"sect"}, mainSections)
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(mainSections, qt.DeepEquals, []string{"sect"})
|
||||
|
||||
th := testHelper{s.Cfg, s.Fs, t}
|
||||
th := newTestHelper(s.Cfg, s.Fs, t)
|
||||
tests := []struct {
|
||||
doc string
|
||||
pluralAware bool
|
||||
|
@ -527,7 +532,7 @@ func TestAbsURLify(t *testing.T) {
|
|||
writeSource(t, fs, filepath.Join("layouts", "blue/single.html"), templateWithURLAbs)
|
||||
|
||||
s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{})
|
||||
th := testHelper{s.Cfg, s.Fs, t}
|
||||
th := newTestHelper(s.Cfg, s.Fs, t)
|
||||
|
||||
tests := []struct {
|
||||
file, expected string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue