Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-21 11:35:15 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-04-08 14:26:17 +0300
commitd070bdf10f14d233288f7318a4e9f7555f070a65 (patch)
treefff8d59f98bdab3027bb45c4e10ca88594332872 /hugofs/fs_test.go
parentb08193971a821fc27e549a73120c15e5e5186775 (diff)
Rework the Destination filesystem to make --renderStaticToDisk work
See #9626
Diffstat (limited to 'hugofs/fs_test.go')
-rw-r--r--hugofs/fs_test.go48
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)
}