mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
committed by
Bjørn Erik Pedersen
parent
8e2fd55923
commit
953f215f32
@@ -56,6 +56,36 @@ func TestBase(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBaseName(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := qt.New(t)
|
||||
|
||||
for _, test := range []struct {
|
||||
path any
|
||||
expect any
|
||||
}{
|
||||
{filepath.FromSlash(`foo/bar.txt`), `bar`},
|
||||
{filepath.FromSlash(`foo/bar/txt `), `txt `},
|
||||
{filepath.FromSlash(`foo/bar.t`), `bar`},
|
||||
{`foo.bar.txt`, `foo.bar`},
|
||||
{`.x`, ``},
|
||||
{``, `.`},
|
||||
// errors
|
||||
{tstNoStringer{}, false},
|
||||
} {
|
||||
|
||||
result, err := ns.BaseName(test.path)
|
||||
|
||||
if b, ok := test.expect.(bool); ok && !b {
|
||||
c.Assert(err, qt.Not(qt.IsNil))
|
||||
continue
|
||||
}
|
||||
|
||||
c.Assert(err, qt.IsNil)
|
||||
c.Assert(result, qt.Equals, test.expect)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
c := qt.New(t)
|
||||
|
Reference in New Issue
Block a user