♻️ Export Config
This commit is contained in:
parent
5c4e66d144
commit
7bd5503613
6 changed files with 56 additions and 38 deletions
|
|
@ -3,47 +3,38 @@ package nomino
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDefaultConf(t *testing.T) {
|
||||
c := defaultConf()
|
||||
assert.Equal(t, ".txt", c.extension)
|
||||
st, _ := c.generator()
|
||||
_, parseErr := uuid.Parse(st)
|
||||
assert.NoError(t, parseErr)
|
||||
}
|
||||
|
||||
func TestWithOriginal(t *testing.T) {
|
||||
var c config
|
||||
var c Config
|
||||
name := "foobar"
|
||||
WithOriginal(name)(&c)
|
||||
assert.Equal(t, "_"+name, c.original)
|
||||
}
|
||||
|
||||
func TestWithPrefix(t *testing.T) {
|
||||
var c config
|
||||
var c Config
|
||||
pref := "draft"
|
||||
WithPrefix(pref)(&c)
|
||||
assert.Equal(t, pref+"_", c.prefix)
|
||||
}
|
||||
|
||||
func TestWithSuffix(t *testing.T) {
|
||||
var c config
|
||||
var c Config
|
||||
suff := "out"
|
||||
WithSuffix(suff)(&c)
|
||||
assert.Equal(t, "_"+suff, c.suffix)
|
||||
}
|
||||
|
||||
func TestWithoutExtension(t *testing.T) {
|
||||
c := config{extension: ".foobar"}
|
||||
c := Config{extension: ".foobar"}
|
||||
WithoutExtension()(&c)
|
||||
assert.Equal(t, "", c.extension)
|
||||
}
|
||||
|
||||
func TestWithExtension(t *testing.T) {
|
||||
var c config
|
||||
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