🐛 Extension was being ignored
This commit is contained in:
parent
ee0b3beeb5
commit
b0b76d02bd
2 changed files with 34 additions and 5 deletions
2
make.go
2
make.go
|
|
@ -11,5 +11,5 @@ func Make(conf Config) (string, error) {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%s%s%s%s%s", conf.prefix, name, conf.original, conf.suffix, conf.original), nil
|
return fmt.Sprintf("%s%s%s%s%s", conf.prefix, name, conf.original, conf.suffix, conf.extension), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
37
make_test.go
37
make_test.go
|
|
@ -8,10 +8,39 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMake(t *testing.T) {
|
func TestMake(t *testing.T) {
|
||||||
conf := NewConfig(WithGenerator(func() (string, error) { return "abc", nil }))
|
genOpt := WithGenerator(func() (string, error) { return "abc", nil })
|
||||||
st, err := Make(conf)
|
testcases := []struct {
|
||||||
assert.NoError(t, err)
|
name string
|
||||||
assert.Equal(t, "abc", st)
|
opts []Option
|
||||||
|
exp string
|
||||||
|
}{
|
||||||
|
{"basic", nil, "abc.txt"},
|
||||||
|
{"with prefix", []Option{WithPrefix("foo")}, "foo_abc.txt"},
|
||||||
|
{"with suffix", []Option{WithSuffix("bar")}, "abc_bar.txt"},
|
||||||
|
{"with original", []Option{WithOriginal("file")}, "abc_file.txt"},
|
||||||
|
{"without ext", []Option{WithoutExtension()}, "abc"},
|
||||||
|
{"with ext", []Option{WithExtension("xml")}, "abc.xml"},
|
||||||
|
{
|
||||||
|
"with all",
|
||||||
|
[]Option{
|
||||||
|
WithPrefix("pre"),
|
||||||
|
WithOriginal("file"),
|
||||||
|
WithSuffix("suff"),
|
||||||
|
WithExtension("svg"),
|
||||||
|
},
|
||||||
|
"pre_abc_file_suff.svg",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testcase := range testcases {
|
||||||
|
t.Run(testcase.name, func(sub *testing.T) {
|
||||||
|
opts := append(testcase.opts, genOpt)
|
||||||
|
conf := NewConfig(opts...)
|
||||||
|
st, err := Make(conf)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, testcase.exp, st)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMakeErr(t *testing.T) {
|
func TestMakeErr(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue