diff options
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r-- | hugolib/filesystems/basefs.go | 24 | ||||
-rw-r--r-- | hugolib/filesystems/basefs_test.go | 231 |
2 files changed, 103 insertions, 152 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index 377428325..b90111e26 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -441,6 +441,8 @@ func WithBaseFs(b *BaseFs) func(*BaseFs) error { } } +var counter int + // NewBase builds the filesystems used by Hugo given the paths and options provided.NewBase func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) error) (*BaseFs, error) { fs := p.Fs @@ -449,14 +451,14 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err } publishFs := hugofs.NewBaseFileDecorator(fs.PublishDir) - sourceFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Source, p.WorkingDir)) + sourceFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Source, p.Cfg.BaseConfig().WorkingDir)) publishFsStatic := fs.PublishDirStatic var buildMu Lockable - if p.Cfg.GetBool("noBuildLock") || htesting.IsTest { + if p.Cfg.NoBuildLock() || htesting.IsTest { buildMu = &fakeLockfileMutex{} } else { - buildMu = lockedfile.MutexAt(filepath.Join(p.WorkingDir, lockFileBuild)) + buildMu = lockedfile.MutexAt(filepath.Join(p.Cfg.BaseConfig().WorkingDir, lockFileBuild)) } b := &BaseFs{ @@ -554,7 +556,7 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) { contentDirs := b.theBigFs.overlayDirs[files.ComponentFolderContent] contentBfs := afero.NewBasePathFs(b.theBigFs.overlayMountsContent, files.ComponentFolderContent) - contentFs, err := hugofs.NewLanguageFs(b.p.LanguagesDefaultFirst.AsOrdinalSet(), contentBfs) + contentFs, err := hugofs.NewLanguageFs(b.p.Cfg.LanguagesDefaultFirst().AsOrdinalSet(), contentBfs) if err != nil { return nil, fmt.Errorf("create content filesystem: %w", err) } @@ -585,9 +587,10 @@ func (b *sourceFilesystemsBuilder) Build() (*SourceFilesystems, error) { func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesystemsCollector, error) { var staticFsMap map[string]*overlayfs.OverlayFs - if b.p.Cfg.GetBool("multihost") { + if b.p.Cfg.IsMultihost() { + languages := b.p.Cfg.Languages() staticFsMap = make(map[string]*overlayfs.OverlayFs) - for _, l := range b.p.Languages { + for _, l := range languages { staticFsMap[l.Lang] = overlayfs.New(overlayfs.Options{}) } } @@ -605,7 +608,7 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys overlayResources: overlayfs.New(overlayfs.Options{FirstWritable: true}), } - mods := p.AllModules + mods := p.AllModules() mounts := make([]mountsDescriptor, len(mods)) @@ -671,7 +674,6 @@ func (b *sourceFilesystemsBuilder) createOverlayFs( } for i, mount := range md.Mounts() { - // Add more weight to early mounts. // When two mounts contain the same filename, // the first entry wins. @@ -705,7 +707,7 @@ func (b *sourceFilesystemsBuilder) createOverlayFs( lang := mount.Lang if lang == "" && isContentMount { - lang = b.p.DefaultContentLanguage + lang = b.p.Cfg.DefaultContentLanguage() } rm.Meta.Lang = lang @@ -745,17 +747,15 @@ func (b *sourceFilesystemsBuilder) createOverlayFs( collector.addDirs(rmfsStatic) if collector.staticPerLanguage != nil { - for _, l := range b.p.Languages { + for _, l := range b.p.Cfg.Languages() { lang := l.Lang lfs := rmfsStatic.Filter(func(rm hugofs.RootMapping) bool { rlang := rm.Meta.Lang return rlang == "" || rlang == lang }) - bfs := afero.NewBasePathFs(lfs, files.ComponentFolderStatic) collector.staticPerLanguage[lang] = collector.staticPerLanguage[lang].Append(bfs) - } } diff --git a/hugolib/filesystems/basefs_test.go b/hugolib/filesystems/basefs_test.go index a729e63b1..1724f3838 100644 --- a/hugolib/filesystems/basefs_test.go +++ b/hugolib/filesystems/basefs_test.go @@ -1,4 +1,4 @@ -// Copyright 2019 The Hugo Authors. All rights reserved. +// Copyright 2023 The Hugo Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package filesystems +package filesystems_test import ( "errors" @@ -21,63 +21,20 @@ import ( "strings" "testing" - "github.com/gobwas/glob" - "github.com/gohugoio/hugo/config" - - "github.com/gohugoio/hugo/langs" + "github.com/gohugoio/hugo/config/testconfig" "github.com/spf13/afero" qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/hugofs" + "github.com/gohugoio/hugo/hugolib/filesystems" "github.com/gohugoio/hugo/hugolib/paths" - "github.com/gohugoio/hugo/modules" ) -func initConfig(fs afero.Fs, cfg config.Provider) error { - if _, err := langs.LoadLanguageSettings(cfg, nil); err != nil { - return err - } - - modConfig, err := modules.DecodeConfig(cfg) - if err != nil { - return err - } - - workingDir := cfg.GetString("workingDir") - themesDir := cfg.GetString("themesDir") - if !filepath.IsAbs(themesDir) { - themesDir = filepath.Join(workingDir, themesDir) - } - globAll := glob.MustCompile("**", '/') - modulesClient := modules.NewClient(modules.ClientConfig{ - Fs: fs, - WorkingDir: workingDir, - ThemesDir: themesDir, - ModuleConfig: modConfig, - IgnoreVendor: globAll, - }) - - moduleConfig, err := modulesClient.Collect() - if err != nil { - return err - } - - if err := modules.ApplyProjectConfigDefaults(cfg, moduleConfig.ActiveModules[0]); err != nil { - return err - } - - cfg.Set("allModules", moduleConfig.ActiveModules) - - return nil -} - func TestNewBaseFs(t *testing.T) { c := qt.New(t) - v := config.NewWithTestDefaults() - - fs := hugofs.NewMem(v) + v := config.New() themes := []string{"btheme", "atheme"} @@ -87,6 +44,9 @@ func TestNewBaseFs(t *testing.T) { v.Set("themesDir", "themes") v.Set("defaultContentLanguage", "en") v.Set("theme", themes[:1]) + v.Set("publishDir", "public") + + afs := afero.NewMemMapFs() // Write some data to the themes for _, theme := range themes { @@ -94,39 +54,39 @@ func TestNewBaseFs(t *testing.T) { base := filepath.Join(workingDir, "themes", theme, dir) filenameTheme := filepath.Join(base, fmt.Sprintf("theme-file-%s.txt", theme)) filenameOverlap := filepath.Join(base, "f3.txt") - fs.Source.Mkdir(base, 0755) + afs.Mkdir(base, 0755) content := []byte(fmt.Sprintf("content:%s:%s", theme, dir)) - afero.WriteFile(fs.Source, filenameTheme, content, 0755) - afero.WriteFile(fs.Source, filenameOverlap, content, 0755) + afero.WriteFile(afs, filenameTheme, content, 0755) + afero.WriteFile(afs, filenameOverlap, content, 0755) } // Write some files to the root of the theme base := filepath.Join(workingDir, "themes", theme) - afero.WriteFile(fs.Source, filepath.Join(base, fmt.Sprintf("theme-root-%s.txt", theme)), []byte(fmt.Sprintf("content:%s", theme)), 0755) - afero.WriteFile(fs.Source, filepath.Join(base, "file-theme-root.txt"), []byte(fmt.Sprintf("content:%s", theme)), 0755) + afero.WriteFile(afs, filepath.Join(base, fmt.Sprintf("theme-root-%s.txt", theme)), []byte(fmt.Sprintf("content:%s", theme)), 0755) + afero.WriteFile(afs, filepath.Join(base, "file-theme-root.txt"), []byte(fmt.Sprintf("content:%s", theme)), 0755) } - afero.WriteFile(fs.Source, filepath.Join(workingDir, "file-root.txt"), []byte("content-project"), 0755) + afero.WriteFile(afs, filepath.Join(workingDir, "file-root.txt"), []byte("content-project"), 0755) - afero.WriteFile(fs.Source, filepath.Join(workingDir, "themes", "btheme", "config.toml"), []byte(` + afero.WriteFile(afs, filepath.Join(workingDir, "themes", "btheme", "config.toml"), []byte(` theme = ["atheme"] `), 0755) - setConfigAndWriteSomeFilesTo(fs.Source, v, "contentDir", "mycontent", 3) - setConfigAndWriteSomeFilesTo(fs.Source, v, "i18nDir", "myi18n", 4) - setConfigAndWriteSomeFilesTo(fs.Source, v, "layoutDir", "mylayouts", 5) - setConfigAndWriteSomeFilesTo(fs.Source, v, "staticDir", "mystatic", 6) - setConfigAndWriteSomeFilesTo(fs.Source, v, "dataDir", "mydata", 7) - setConfigAndWriteSomeFilesTo(fs.Source, v, "archetypeDir", "myarchetypes", 8) - setConfigAndWriteSomeFilesTo(fs.Source, v, "assetDir", "myassets", 9) - setConfigAndWriteSomeFilesTo(fs.Source, v, "resourceDir", "myrsesource", 10) + setConfigAndWriteSomeFilesTo(afs, v, "contentDir", "mycontent", 3) + setConfigAndWriteSomeFilesTo(afs, v, "i18nDir", "myi18n", 4) + setConfigAndWriteSomeFilesTo(afs, v, "layoutDir", "mylayouts", 5) + setConfigAndWriteSomeFilesTo(afs, v, "staticDir", "mystatic", 6) + setConfigAndWriteSomeFilesTo(afs, v, "dataDir", "mydata", 7) + setConfigAndWriteSomeFilesTo(afs, v, "archetypeDir", "myarchetypes", 8) + setConfigAndWriteSomeFilesTo(afs, v, "assetDir", "myassets", 9) + setConfigAndWriteSomeFilesTo(afs, v, "resourceDir", "myrsesource", 10) - v.Set("publishDir", "public") - c.Assert(initConfig(fs.Source, v), qt.IsNil) + conf := testconfig.GetTestConfig(afs, v) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) - p, err := paths.New(fs, v) + p, err := paths.New(fs, conf) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) c.Assert(bfs, qt.Not(qt.IsNil)) @@ -180,31 +140,14 @@ theme = ["atheme"] } } -func createConfig() config.Provider { - v := config.NewWithTestDefaults() - v.Set("contentDir", "mycontent") - v.Set("i18nDir", "myi18n") - v.Set("staticDir", "mystatic") - v.Set("dataDir", "mydata") - v.Set("layoutDir", "mylayouts") - v.Set("archetypeDir", "myarchetypes") - v.Set("assetDir", "myassets") - v.Set("resourceDir", "resources") - v.Set("publishDir", "public") - v.Set("defaultContentLanguage", "en") - - return v -} - func TestNewBaseFsEmpty(t *testing.T) { c := qt.New(t) - v := createConfig() - fs := hugofs.NewMem(v) - c.Assert(initConfig(fs.Source, v), qt.IsNil) - - p, err := paths.New(fs, v) + afs := afero.NewMemMapFs() + conf := testconfig.GetTestConfig(afs, nil) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) + p, err := paths.New(fs, conf) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) c.Assert(bfs, qt.Not(qt.IsNil)) c.Assert(bfs.Archetypes.Fs, qt.Not(qt.IsNil)) @@ -218,47 +161,47 @@ func TestNewBaseFsEmpty(t *testing.T) { func TestRealDirs(t *testing.T) { c := qt.New(t) - v := createConfig() + v := config.New() root, themesDir := t.TempDir(), t.TempDir() v.Set("workingDir", root) v.Set("themesDir", themesDir) + v.Set("assetDir", "myassets") v.Set("theme", "mytheme") - fs := hugofs.NewDefault(v) - sfs := fs.Source + afs := hugofs.Os defer func() { os.RemoveAll(root) os.RemoveAll(themesDir) }() - c.Assert(sfs.MkdirAll(filepath.Join(root, "myassets", "scss", "sf1"), 0755), qt.IsNil) - c.Assert(sfs.MkdirAll(filepath.Join(root, "myassets", "scss", "sf2"), 0755), qt.IsNil) - c.Assert(sfs.MkdirAll(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf2"), 0755), qt.IsNil) - c.Assert(sfs.MkdirAll(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf3"), 0755), qt.IsNil) - c.Assert(sfs.MkdirAll(filepath.Join(root, "resources"), 0755), qt.IsNil) - c.Assert(sfs.MkdirAll(filepath.Join(themesDir, "mytheme", "resources"), 0755), qt.IsNil) - - c.Assert(sfs.MkdirAll(filepath.Join(root, "myassets", "js", "f2"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(root, "myassets", "scss", "sf1"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(root, "myassets", "scss", "sf2"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf2"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf3"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(root, "resources"), 0755), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(themesDir, "mytheme", "resources"), 0755), qt.IsNil) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "myassets", "scss", "sf1", "a1.scss")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "myassets", "scss", "sf2", "a3.scss")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "myassets", "scss", "a2.scss")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf2", "a3.scss")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf3", "a4.scss")), []byte("content"), 0755) + c.Assert(afs.MkdirAll(filepath.Join(root, "myassets", "js", "f2"), 0755), qt.IsNil) - afero.WriteFile(sfs, filepath.Join(filepath.Join(themesDir, "mytheme", "resources", "t1.txt")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "resources", "p1.txt")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "resources", "p2.txt")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "myassets", "scss", "sf1", "a1.scss")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "myassets", "scss", "sf2", "a3.scss")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "myassets", "scss", "a2.scss")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf2", "a3.scss")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(themesDir, "mytheme", "assets", "scss", "sf3", "a4.scss")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "myassets", "js", "f2", "a1.js")), []byte("content"), 0755) - afero.WriteFile(sfs, filepath.Join(filepath.Join(root, "myassets", "js", "a2.js")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(themesDir, "mytheme", "resources", "t1.txt")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "resources", "p1.txt")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "resources", "p2.txt")), []byte("content"), 0755) - c.Assert(initConfig(fs.Source, v), qt.IsNil) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "myassets", "js", "f2", "a1.js")), []byte("content"), 0755) + afero.WriteFile(afs, filepath.Join(filepath.Join(root, "myassets", "js", "a2.js")), []byte("content"), 0755) - p, err := paths.New(fs, v) + conf := testconfig.GetTestConfig(afs, v) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) + p, err := paths.New(fs, conf) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) c.Assert(bfs, qt.Not(qt.IsNil)) @@ -269,45 +212,48 @@ func TestRealDirs(t *testing.T) { c.Assert(realDirs[0], qt.Equals, filepath.Join(root, "myassets/scss")) c.Assert(realDirs[len(realDirs)-1], qt.Equals, filepath.Join(themesDir, "mytheme/assets/scss")) - c.Assert(bfs.theBigFs, qt.Not(qt.IsNil)) } func TestStaticFs(t *testing.T) { c := qt.New(t) - v := createConfig() + v := config.New() workDir := "mywork" v.Set("workingDir", workDir) v.Set("themesDir", "themes") + v.Set("staticDir", "mystatic") v.Set("theme", []string{"t1", "t2"}) - fs := hugofs.NewMem(v) + afs := afero.NewMemMapFs() themeStaticDir := filepath.Join(workDir, "themes", "t1", "static") themeStaticDir2 := filepath.Join(workDir, "themes", "t2", "static") - afero.WriteFile(fs.Source, filepath.Join(workDir, "mystatic", "f1.txt"), []byte("Hugo Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(themeStaticDir, "f1.txt"), []byte("Hugo Themes Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(themeStaticDir, "f2.txt"), []byte("Hugo Themes Still Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(themeStaticDir2, "f2.txt"), []byte("Hugo Themes Rocks in t2!"), 0755) + afero.WriteFile(afs, filepath.Join(workDir, "mystatic", "f1.txt"), []byte("Hugo Rocks!"), 0755) + afero.WriteFile(afs, filepath.Join(themeStaticDir, "f1.txt"), []byte("Hugo Themes Rocks!"), 0755) + afero.WriteFile(afs, filepath.Join(themeStaticDir, "f2.txt"), []byte("Hugo Themes Still Rocks!"), 0755) + afero.WriteFile(afs, filepath.Join(themeStaticDir2, "f2.txt"), []byte("Hugo Themes Rocks in t2!"), 0755) - c.Assert(initConfig(fs.Source, v), qt.IsNil) + conf := testconfig.GetTestConfig(afs, v) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) + p, err := paths.New(fs, conf) - p, err := paths.New(fs, v) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) sfs := bfs.StaticFs("en") + checkFileContent(sfs, "f1.txt", c, "Hugo Rocks!") checkFileContent(sfs, "f2.txt", c, "Hugo Themes Still Rocks!") } func TestStaticFsMultiHost(t *testing.T) { c := qt.New(t) - v := createConfig() + v := config.New() workDir := "mywork" v.Set("workingDir", workDir) v.Set("themesDir", "themes") + v.Set("staticDir", "mystatic") v.Set("theme", "t1") v.Set("defaultContentLanguage", "en") @@ -323,21 +269,24 @@ func TestStaticFsMultiHost(t *testing.T) { v.Set("languages", langConfig) - fs := hugofs.NewMem(v) + afs := afero.NewMemMapFs() themeStaticDir := filepath.Join(workDir, "themes", "t1", "static") - afero.WriteFile(fs.Source, filepath.Join(workDir, "mystatic", "f1.txt"), []byte("Hugo Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(workDir, "static_no", "f1.txt"), []byte("Hugo Rocks in Norway!"), 0755) + afero.WriteFile(afs, filepath.Join(workDir, "mystatic", "f1.txt"), []byte("Hugo Rocks!"), 0755) + afero.WriteFile(afs, filepath.Join(workDir, "static_no", "f1.txt"), []byte("Hugo Rocks in Norway!"), 0755) + + afero.WriteFile(afs, filepath.Join(themeStaticDir, "f1.txt"), []byte("Hugo Themes Rocks!"), 0755) + afero.WriteFile(afs, filepath.Join(themeStaticDir, "f2.txt"), []byte("Hugo Themes Still Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(themeStaticDir, "f1.txt"), []byte("Hugo Themes Rocks!"), 0755) - afero.WriteFile(fs.Source, filepath.Join(themeStaticDir, "f2.txt"), []byte("Hugo Themes Still Rocks!"), 0755) + conf := testconfig.GetTestConfig(afs, v) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) - c.Assert(initConfig(fs.Source, v), qt.IsNil) + fmt.Println("IS", conf.IsMultihost()) - p, err := paths.New(fs, v) + p, err := paths.New(fs, conf) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) enFs := bfs.StaticFs("en") checkFileContent(enFs, "f1.txt", c, "Hugo Rocks!") @@ -350,14 +299,14 @@ func TestStaticFsMultiHost(t *testing.T) { func TestMakePathRelative(t *testing.T) { c := qt.New(t) - v := createConfig() - fs := hugofs.NewMem(v) + v := config.New() + afs := afero.NewMemMapFs() workDir := "mywork" v.Set("workingDir", workDir) - c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "dist", "d1"), 0777), qt.IsNil) - c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "static", "d2"), 0777), qt.IsNil) - c.Assert(fs.Source.MkdirAll(filepath.Join(workDir, "dust", "d2"), 0777), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(workDir, "dist", "d1"), 0777), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(workDir, "static", "d2"), 0777), qt.IsNil) + c.Assert(afs.MkdirAll(filepath.Join(workDir, "dust", "d2"), 0777), qt.IsNil) moduleCfg := map[string]any{ "mounts": []any{ @@ -378,11 +327,12 @@ func TestMakePathRelative(t *testing.T) { v.Set("module", moduleCfg) - c.Assert(initConfig(fs.Source, v), qt.IsNil) + conf := testconfig.GetTestConfig(afs, v) + fs := hugofs.NewFrom(afs, conf.BaseConfig()) - p, err := paths.New(fs, v) + p, err := paths.New(fs, conf) c.Assert(err, qt.IsNil) - bfs, err := NewBase(p, nil) + bfs, err := filesystems.NewBase(p, nil) c.Assert(err, qt.IsNil) sfs := bfs.Static[""] @@ -399,6 +349,7 @@ func TestMakePathRelative(t *testing.T) { } func checkFileCount(fs afero.Fs, dirname string, c *qt.C, expected int) { + c.Helper() count, _, err := countFilesAndGetFilenames(fs, dirname) c.Assert(err, qt.IsNil) c.Assert(count, qt.Equals, expected) |