🔀 Merge branch 'hotfix/0.0.2' into stable

This commit is contained in:
Dan Jones 2025-03-11 12:44:34 -05:00
commit 2f4a42f784
4 changed files with 43 additions and 6 deletions

View file

@ -1,5 +1,13 @@
# Changelog
## [0.0.2] - 2025-03-11
Bugfix release
### Fixes
- Extension being ignored. Original included twice.
## [0.0.1] - 2025-03-10
Initial Release! Hope you like it!

View file

@ -8,4 +8,4 @@ It takes a lot of inspiration (although no actual code) from [Onym](https://gith
I'll fill this out more in depth later.
For now, add it to a new project, and run `go doc codeberg.org/danjones000/nomino`
For now, check [official documentation](https://pkg.go.dev/codeberg.org/danjones000/nomino).

View file

@ -11,5 +11,5 @@ func Make(conf Config) (string, error) {
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
}

View file

@ -8,10 +8,39 @@ import (
)
func TestMake(t *testing.T) {
conf := NewConfig(WithGenerator(func() (string, error) { return "abc", nil }))
st, err := Make(conf)
assert.NoError(t, err)
assert.Equal(t, "abc", st)
genOpt := WithGenerator(func() (string, error) { return "abc", nil })
testcases := []struct {
name string
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) {