Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: style change
  • Loading branch information
rymut committed Dec 23, 2024
commit c42736697ae3a84db827ff887f1b59da2daa1847
2 changes: 1 addition & 1 deletion hugofs/rootmapping_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ func (f *rootMappingDir) ReadDir(count int) ([]iofs.DirEntry, error) {
meta := fim.Meta()
if f.meta.InclusionFilter.Match(strings.TrimPrefix(meta.Filename, meta.SourceRoot), fim.IsDir()) {
result = append(result, fim)
}
}
}
return result, nil
}
Expand Down
8 changes: 4 additions & 4 deletions hugofs/rootmapping_fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/gohugoio/hugo/hugofs/glob"

qt "github.com/frankban/quicktest"
"github.com/google/go-cmp/cmp"
"github.com/gohugoio/hugo/htesting"
"github.com/google/go-cmp/cmp"
"github.com/spf13/afero"
)

Expand Down Expand Up @@ -331,7 +331,7 @@ func TestReaddirRootMappingFsMountOverlap(t *testing.T) {
},
{
From: "/static/file.txt",
To: "de/e.txt",
To: "de/e.txt",
},
}

Expand Down Expand Up @@ -365,15 +365,15 @@ func TestReaddirRootMappingFsMountOverlap(t *testing.T) {
_, name = filepath.Split(name)
expectNames[i] = name
}

// check names
c.Assert(actualNames, qt.DeepEquals, expectNames, qt.Commentf(fmt.Sprintf("%#v", actualNames)))
// check other props
comp := func(x iofs.FileInfo, y iofs.FileInfo) bool {
if x == nil && y == nil {
return true
}
return x != nil && y != nil &&
return x != nil && y != nil &&
x.Mode() == y.Mode() &&
x.ModTime() == y.ModTime() &&
x.Size() == y.Size() &&
Expand Down
8 changes: 4 additions & 4 deletions tpl/os/os.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ func New(d *deps.Deps) *Namespace {
}

return &Namespace{
mountsFs: mountsFs,
deps: d,
mountsFs: mountsFs,
deps: d,
}
}

// Namespace provides template functions for the "os" namespace.
type Namespace struct {
mountsFs afero.Fs
deps *deps.Deps
mountsFs afero.Fs
deps *deps.Deps
}

// Getenv retrieves the value of the environment variable named by the key.
Expand Down
28 changes: 14 additions & 14 deletions tpl/os/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ func TestFileExists(t *testing.T) {

for _, test := range []struct {
filename string
expect any
comment string
expect any
comment string
}{
{filepath.FromSlash("f/f1.txt"), true, "must be present in workdir"},
{filepath.FromSlash("../f2.txt"), false, "cannot exist" },
{filepath.FromSlash("../f2.txt"), false, "cannot exist"},
{filepath.FromSlash("about.pl.md"), true, "must be present in contentDir"},
{filepath.FromSlash("en/about.md"), true, "must be present in contentDir"},
{filepath.FromSlash("assets/testing.json"), true, "mapping must be present"},
Expand All @@ -99,7 +99,7 @@ func TestFileExists(t *testing.T) {
continue
}

b.Assert(err, qt.IsNil, qt.Commentf("file '%s' %s", filename, test.comment))
b.Assert(err, qt.IsNil, qt.Commentf("file '%s' %s", filename, test.comment))
b.Assert(result, qt.Equals, test.expect, qt.Commentf("file '%s' %s", filename, test.comment))
}
}
Expand All @@ -111,14 +111,14 @@ func TestStat(t *testing.T) {
ns := os.New(b.H.Deps)

for _, test := range []struct {
filename string
expectError bool
expectSize any
expectIsDir any
comment string
filename string
expectError bool
expectSize any
expectIsDir any
comment string
}{
{filepath.FromSlash("f/f1.txt"), false, int64(10), false, "must be present in workdir"},
{filepath.FromSlash("../f2.txt"), true, nil, nil, "cannot exist" },
{filepath.FromSlash("../f2.txt"), true, nil, nil, "cannot exist"},
{filepath.FromSlash("about.pl.md"), false, int64(2), false, "must be present in contentDir"},
{filepath.FromSlash("en/about.md"), false, int64(2), false, "must be present in contentDir"},
{filepath.FromSlash("assets/testing.json"), false, int64(13), false, "mapping must be present"},
Expand All @@ -142,13 +142,13 @@ func TestStat(t *testing.T) {
b.Assert(err, qt.Not(qt.IsNil), qt.Commentf("file '%s' %s", filename, test.comment))
continue
}
b.Assert(err, qt.IsNil, qt.Commentf("file '%s' %s", filename, test.comment))

b.Assert(err, qt.IsNil, qt.Commentf("file '%s' %s", filename, test.comment))
if test.expectSize != nil {
// size for is dir is platform dependent
b.Assert(result.Size(), qt.Equals, test.expectSize, qt.Commentf("file '%s' invalid size", filename))
}
b.Assert(result.IsDir(), qt.Equals, test.expectIsDir, qt.Commentf("file '%s' must be directory", filename))
b.Assert(result.IsDir(), qt.Equals, test.expectIsDir, qt.Commentf("file '%s' must be directory", filename))
}
}
}
Expand Down Expand Up @@ -197,7 +197,7 @@ raw1-content
-- themes/module2/assets/file2.json --
file2-content
`

return hugolib.NewIntegrationTestBuilder(
hugolib.IntegrationTestConfig{
T: t,
Expand Down