mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-27 22:09:53 +02:00
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
This commit is contained in:
@@ -27,9 +27,7 @@ import (
|
||||
)
|
||||
|
||||
func NewTestResourceSpec() (*resources.Spec, error) {
|
||||
cfg := config.New()
|
||||
cfg.Set("baseURL", "https://example.org")
|
||||
cfg.Set("publishDir", "public")
|
||||
cfg := config.NewWithTestDefaults()
|
||||
|
||||
imagingCfg := map[string]any{
|
||||
"resampleFilter": "linear",
|
||||
|
@@ -79,7 +79,7 @@ func newTestResourceSpec(desc specDescriptor) *Spec {
|
||||
cfg.Set("imaging", imagingCfg)
|
||||
|
||||
fs := hugofs.NewFrom(afs, cfg)
|
||||
fs.Destination = hugofs.NewCreateCountingFs(fs.Destination)
|
||||
fs.PublishDir = hugofs.NewCreateCountingFs(fs.PublishDir)
|
||||
|
||||
s, err := helpers.NewPathSpec(fs, cfg, nil)
|
||||
c.Assert(err, qt.IsNil)
|
||||
@@ -118,7 +118,6 @@ func newTestResourceOsFs(c *qt.C) (*Spec, string) {
|
||||
cfg.Set("workingDir", workDir)
|
||||
|
||||
fs := hugofs.NewFrom(hugofs.NewBaseFileDecorator(hugofs.Os), cfg)
|
||||
fs.Destination = &afero.MemMapFs{}
|
||||
|
||||
s, err := helpers.NewPathSpec(fs, cfg, nil)
|
||||
c.Assert(err, qt.IsNil)
|
||||
|
@@ -70,13 +70,13 @@ func TestTransform(t *testing.T) {
|
||||
// Verify that we publish the same file once only.
|
||||
assertNoDuplicateWrites := func(c *qt.C, spec *Spec) {
|
||||
c.Helper()
|
||||
d := spec.Fs.Destination.(hugofs.DuplicatesReporter)
|
||||
d := spec.Fs.PublishDir.(hugofs.DuplicatesReporter)
|
||||
c.Assert(d.ReportDuplicates(), qt.Equals, "")
|
||||
}
|
||||
|
||||
assertShouldExist := func(c *qt.C, spec *Spec, filename string, should bool) {
|
||||
c.Helper()
|
||||
exists, _ := helpers.Exists(filepath.FromSlash(filename), spec.Fs.Destination)
|
||||
exists, _ := helpers.Exists(filepath.FromSlash(filename), spec.Fs.WorkingDirReadOnly)
|
||||
c.Assert(exists, qt.Equals, should)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user