diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-10-29 17:14:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-10-30 09:41:05 +0100 |
commit | 173187e2633f3fc037c83e1e3de2902ae3c93b92 (patch) | |
tree | 92fbe7d0cd7dddf2eb229b074f24120c15d0407a /modules/client_test.go | |
parent | 8a1c637c4494751046142e0ef345fce38fc1431b (diff) |
Add module.replacements
Fixes #7904
Fixes #7908
Diffstat (limited to 'modules/client_test.go')
-rw-r--r-- | modules/client_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/modules/client_test.go b/modules/client_test.go index 41509a9ed..7354f15e8 100644 --- a/modules/client_test.go +++ b/modules/client_test.go @@ -15,6 +15,8 @@ package modules import ( "bytes" + "os" + "path/filepath" "testing" "github.com/gohugoio/hugo/hugofs/glob" @@ -41,10 +43,14 @@ github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 github.com/gohugoio/h workingDir, clean, err := htesting.CreateTempDir(hugofs.Os, modName) c.Assert(err, qt.IsNil) + themesDir := filepath.Join(workingDir, "themes") + err = os.Mkdir(themesDir, 0777) + c.Assert(err, qt.IsNil) ccfg := ClientConfig{ Fs: hugofs.Os, WorkingDir: workingDir, + ThemesDir: themesDir, } withConfig(&ccfg) @@ -131,6 +137,28 @@ project github.com/gohugoio/hugoTestModules1_darwin/modh2_2_2@v1.3.0+vendor c.Assert(graphb.String(), qt.Equals, expect) }) + // https://github.com/gohugoio/hugo/issues/7908 + c.Run("createThemeDirname", func(c *qt.C) { + mcfg := DefaultModuleConfig + client, clean := newClient( + c, func(cfg *ClientConfig) { + cfg.ModuleConfig = mcfg + }) + defer clean() + + dirname, err := client.createThemeDirname("foo", false) + c.Assert(err, qt.IsNil) + c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "foo")) + + dirname, err = client.createThemeDirname("../../foo", true) + c.Assert(err, qt.IsNil) + c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "../../foo")) + + dirname, err = client.createThemeDirname("../../foo", false) + c.Assert(err, qt.Not(qt.IsNil)) + + }) + } var globAll, _ = glob.GetGlob("**") |