diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-03-21 09:35:15 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-04-08 13:26:17 +0200 |
commit | d070bdf10f14d233288f7318a4e9f7555f070a65 (patch) | |
tree | fff8d59f98bdab3027bb45c4e10ca88594332872 /hugofs/fs_test.go | |
parent | b08193971a821fc27e549a73120c15e5e5186775 (diff) |
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
Diffstat (limited to 'hugofs/fs_test.go')
-rw-r--r-- | hugofs/fs_test.go | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/hugofs/fs_test.go b/hugofs/fs_test.go index 8d52267af..f7203fac9 100644 --- a/hugofs/fs_test.go +++ b/hugofs/fs_test.go @@ -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) } |