summaryrefslogtreecommitdiffstats
path: root/commands/hugo_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-07 14:10:32 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-05-08 16:56:26 +0200
commit35c88a7f907f20652e4e55697c0c438da0c4d57d (patch)
tree0c4d5b9fc4b40e34dc59c2063d2a451b020b1cd5 /commands/hugo_test.go
parente77ca3c105bd64c5077d823d2127f6f812a4f681 (diff)
Use configured timeZone for the clock
And some other related adjustments. Updates #8787
Diffstat (limited to 'commands/hugo_test.go')
-rw-r--r--commands/hugo_test.go30
1 files changed, 23 insertions, 7 deletions
diff --git a/commands/hugo_test.go b/commands/hugo_test.go
index 61160b7dd..1e1326642 100644
--- a/commands/hugo_test.go
+++ b/commands/hugo_test.go
@@ -21,7 +21,9 @@ import (
"strings"
"testing"
+ "github.com/bep/clock"
qt "github.com/frankban/quicktest"
+ "github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/hugofs"
"github.com/spf13/afero"
"golang.org/x/tools/txtar"
@@ -29,6 +31,7 @@ import (
// Issue #5662
func TestHugoWithContentDirOverride(t *testing.T) {
+ t.Parallel()
c := qt.New(t)
files := `
@@ -50,6 +53,7 @@ Page: {{ .Title }}|
// Issue #9794
func TestHugoStaticFilesMultipleStaticAndManyFolders(t *testing.T) {
+ t.Parallel()
c := qt.New(t)
files := `
@@ -95,12 +99,15 @@ Home.
// Issue #8787
func TestHugoListCommandsWithClockFlag(t *testing.T) {
+ t.Cleanup(func() { htime.Clock = clock.System() })
+
c := qt.New(t)
files := `
-- config.toml --
baseURL = "https://example.org"
title = "Hugo Commands"
+timeZone = "UTC"
-- content/past.md --
---
title: "Past"
@@ -115,7 +122,9 @@ date: 2200-11-06
Page: {{ .Title }}|
`
- s := newTestHugoCmdBuilder(c, files, []string{"list", "future"}).Build()
+ s := newTestHugoCmdBuilder(c, files, []string{"list", "future"})
+ s.captureOut = true
+ s.Build()
p := filepath.Join("content", "future.md")
s.AssertStdout(p + ",2200-11-06T00:00:00Z")
@@ -130,7 +139,9 @@ type testHugoCmdBuilder struct {
dir string
files string
args []string
- out string
+
+ captureOut bool
+ out string
}
func newTestHugoCmdBuilder(c *qt.C, files string, args []string) *testHugoCmdBuilder {
@@ -156,12 +167,17 @@ func (s *testHugoCmdBuilder) Build() *testHugoCmdBuilder {
args := append(s.args, "-s="+s.dir, "--quiet")
cmd.SetArgs(args)
- out, err := captureStdout(func() error {
+ if s.captureOut {
+ out, err := captureStdout(func() error {
+ _, err := cmd.ExecuteC()
+ return err
+ })
+ s.Assert(err, qt.IsNil)
+ s.out = out
+ } else {
_, err := cmd.ExecuteC()
- return err
- })
- s.Assert(err, qt.IsNil)
- s.out = out
+ s.Assert(err, qt.IsNil)
+ }
return s
}