Rework the Destination filesystem to make --renderStaticToDisk work

See #9626
This commit is contained in:
Bjørn Erik Pedersen
2022-03-21 09:35:15 +01:00
parent b08193971a
commit d070bdf10f
75 changed files with 651 additions and 566 deletions

View File

@@ -23,7 +23,6 @@ import (
"time"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/markup/asciidocext"
"github.com/gohugoio/hugo/markup/rst"
@@ -35,7 +34,6 @@ import (
"github.com/gohugoio/hugo/resources/page"
"github.com/gohugoio/hugo/resources/resource"
"github.com/spf13/afero"
"github.com/spf13/jwalterweatherman"
qt "github.com/frankban/quicktest"
@@ -1031,14 +1029,14 @@ func TestPageWithLastmodFromGitInfo(t *testing.T) {
}
c := qt.New(t)
// We need to use the OS fs for this.
cfg := config.New()
fs := hugofs.NewFrom(hugofs.Os, cfg)
fs.Destination = &afero.MemMapFs{}
wd, err := os.Getwd()
c.Assert(err, qt.IsNil)
// We need to use the OS fs for this.
cfg := config.NewWithTestDefaults()
cfg.Set("workingDir", filepath.Join(wd, "testsite"))
fs := hugofs.NewFrom(hugofs.Os, cfg)
cfg.Set("frontmatter", map[string]any{
"lastmod": []string{":git", "lastmod"},
})
@@ -1060,8 +1058,6 @@ func TestPageWithLastmodFromGitInfo(t *testing.T) {
cfg.Set("languages", langConfig)
cfg.Set("enableGitInfo", true)
cfg.Set("workingDir", filepath.Join(wd, "testsite"))
b := newTestSitesBuilderFromDepsCfg(t, deps.DepsCfg{Fs: fs, Cfg: cfg}).WithNothingAdded()
b.Build(BuildCfg{SkipRender: true})
@@ -1314,7 +1310,7 @@ func TestChompBOM(t *testing.T) {
func TestPageWithEmoji(t *testing.T) {
for _, enableEmoji := range []bool{true, false} {
v := config.New()
v := config.NewWithTestDefaults()
v.Set("enableEmoji", enableEmoji)
b := newTestSitesBuilder(t).WithViper(v)