summaryrefslogtreecommitdiffstats
path: root/hugolib/page_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'hugolib/page_test.go')
-rw-r--r--hugolib/page_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/hugolib/page_test.go b/hugolib/page_test.go
index 905793ca6..875c5bdde 100644
--- a/hugolib/page_test.go
+++ b/hugolib/page_test.go
@@ -18,6 +18,7 @@ import (
"fmt"
"html/template"
"os"
+
"path/filepath"
"reflect"
"sort"
@@ -25,6 +26,11 @@ import (
"testing"
"time"
+ "github.com/gohugoio/hugo/hugofs"
+ "github.com/spf13/afero"
+
+ "github.com/spf13/viper"
+
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cast"
@@ -904,6 +910,32 @@ func TestPageWithDate(t *testing.T) {
checkPageDate(t, p, d)
}
+func TestPageWithLastmodFromGitInfo(t *testing.T) {
+ assrt := require.New(t)
+
+ // We need to use the OS fs for this.
+ cfg := viper.New()
+ fs := hugofs.NewFrom(hugofs.Os, cfg)
+ fs.Destination = &afero.MemMapFs{}
+
+ cfg.Set("frontmatter", map[string]interface{}{
+ "lastmod": []string{":git", "lastmod"},
+ })
+
+ cfg.Set("enableGitInfo", true)
+
+ assrt.NoError(loadDefaultSettingsFor(cfg))
+
+ wd, err := os.Getwd()
+ assrt.NoError(err)
+ cfg.Set("workingDir", filepath.Join(wd, "testsite"))
+
+ s := buildSingleSite(t, deps.DepsCfg{Fs: fs, Cfg: cfg}, BuildCfg{SkipRender: true})
+
+ assrt.Len(s.RegularPages, 1)
+ assrt.Equal("2018-02-28", s.RegularPages[0].Lastmod.Format("2006-01-02"))
+}
+
func TestPageWithFrontMatterConfig(t *testing.T) {
t.Parallel()