diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-08-10 21:05:17 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-08-12 13:26:32 +0200 |
commit | 9e571827055dedb46b78c5db3d17d6913f14870b (patch) | |
tree | f5f0108afe0c9385ff6dc27664943d9f719f57ad /hugolib/site_test.go | |
parent | 6027ee11082d0b9d72de1d4d1980a702be294ad2 (diff) | |
download | hugo-9e571827055dedb46b78c5db3d17d6913f14870b.tar.gz hugo-9e571827055dedb46b78c5db3d17d6913f14870b.zip |
tests: Convert from testify to quicktest
Diffstat (limited to 'hugolib/site_test.go')
-rw-r--r-- | hugolib/site_test.go | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/hugolib/site_test.go b/hugolib/site_test.go index bbf101fc4..74424cd3d 100644 --- a/hugolib/site_test.go +++ b/hugolib/site_test.go @@ -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 |