mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-17 21:01:26 +02:00
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
This commit is contained in:
@@ -23,38 +23,46 @@ import (
|
||||
"github.com/spf13/afero"
|
||||
)
|
||||
|
||||
func TestIsOsFs(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
|
||||
c.Assert(IsOsFs(Os), qt.Equals, true)
|
||||
c.Assert(IsOsFs(&afero.MemMapFs{}), qt.Equals, false)
|
||||
c.Assert(IsOsFs(afero.NewBasePathFs(&afero.MemMapFs{}, "/public")), qt.Equals, false)
|
||||
c.Assert(IsOsFs(afero.NewBasePathFs(Os, t.TempDir())), qt.Equals, true)
|
||||
|
||||
}
|
||||
|
||||
func TestNewDefault(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
v := config.New()
|
||||
v := config.NewWithTestDefaults()
|
||||
v.Set("workingDir", t.TempDir())
|
||||
f := NewDefault(v)
|
||||
|
||||
c.Assert(f.Source, qt.Not(qt.IsNil))
|
||||
c.Assert(f.Source, qt.IsNotNil)
|
||||
c.Assert(f.Source, hqt.IsSameType, new(afero.OsFs))
|
||||
c.Assert(f.Os, qt.Not(qt.IsNil))
|
||||
c.Assert(f.WorkingDir, qt.IsNil)
|
||||
c.Assert(f.Os, qt.IsNotNil)
|
||||
c.Assert(f.WorkingDirReadOnly, qt.IsNotNil)
|
||||
c.Assert(f.WorkingDirReadOnly, hqt.IsSameType, new(afero.BasePathFs))
|
||||
c.Assert(IsOsFs(f.Source), qt.IsTrue)
|
||||
c.Assert(IsOsFs(f.WorkingDirReadOnly), qt.IsTrue)
|
||||
c.Assert(IsOsFs(f.PublishDir), qt.IsTrue)
|
||||
c.Assert(IsOsFs(f.Os), qt.IsTrue)
|
||||
}
|
||||
|
||||
func TestNewMem(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
v := config.New()
|
||||
v := config.NewWithTestDefaults()
|
||||
f := NewMem(v)
|
||||
|
||||
c.Assert(f.Source, qt.Not(qt.IsNil))
|
||||
c.Assert(f.Source, hqt.IsSameType, new(afero.MemMapFs))
|
||||
c.Assert(f.Destination, qt.Not(qt.IsNil))
|
||||
c.Assert(f.Destination, hqt.IsSameType, new(afero.MemMapFs))
|
||||
c.Assert(f.PublishDir, qt.Not(qt.IsNil))
|
||||
c.Assert(f.PublishDir, hqt.IsSameType, new(afero.BasePathFs))
|
||||
c.Assert(f.Os, hqt.IsSameType, new(afero.OsFs))
|
||||
c.Assert(f.WorkingDir, qt.IsNil)
|
||||
}
|
||||
|
||||
func TestWorkingDir(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
v := config.New()
|
||||
|
||||
v.Set("workingDir", "/a/b/")
|
||||
|
||||
f := NewMem(v)
|
||||
|
||||
c.Assert(f.WorkingDir, qt.Not(qt.IsNil))
|
||||
c.Assert(f.WorkingDir, hqt.IsSameType, new(afero.BasePathFs))
|
||||
c.Assert(f.WorkingDirReadOnly, qt.IsNotNil)
|
||||
c.Assert(IsOsFs(f.Source), qt.IsFalse)
|
||||
c.Assert(IsOsFs(f.WorkingDirReadOnly), qt.IsFalse)
|
||||
c.Assert(IsOsFs(f.PublishDir), qt.IsFalse)
|
||||
c.Assert(IsOsFs(f.Os), qt.IsTrue)
|
||||
}
|
||||
|
Reference in New Issue
Block a user