✨ Add options.go
This commit is contained in:
parent
511a81cab3
commit
bd8f9ae8a6
4 changed files with 118 additions and 0 deletions
48
options_test.go
Normal file
48
options_test.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package nomino
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDefaultConf(t *testing.T) {
|
||||
c := defaultConf()
|
||||
assert.Equal(t, ".txt", c.extension)
|
||||
// assert.Nil(t, c.generator)
|
||||
assert.Equal(t, "abc", c.generator())
|
||||
}
|
||||
|
||||
func TestWithOriginal(t *testing.T) {
|
||||
var c config
|
||||
name := "foobar"
|
||||
WithOriginal(name)(&c)
|
||||
assert.Equal(t, "_"+name, c.original)
|
||||
}
|
||||
|
||||
func TestWithPrefix(t *testing.T) {
|
||||
var c config
|
||||
pref := "draft"
|
||||
WithPrefix(pref)(&c)
|
||||
assert.Equal(t, pref+"_", c.prefix)
|
||||
}
|
||||
|
||||
func TestWithSuffix(t *testing.T) {
|
||||
var c config
|
||||
suff := "out"
|
||||
WithSuffix(suff)(&c)
|
||||
assert.Equal(t, "_"+suff, c.suffix)
|
||||
}
|
||||
|
||||
func TestWithoutExtension(t *testing.T) {
|
||||
c := config{extension: ".foobar"}
|
||||
WithoutExtension()(&c)
|
||||
assert.Equal(t, "", c.extension)
|
||||
}
|
||||
|
||||
func TestWithExtension(t *testing.T) {
|
||||
var c config
|
||||
ext := "yaml"
|
||||
WithExtension(ext)(&c)
|
||||
assert.Equal(t, "."+ext, c.extension)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue