nomino/options_test.go

49 lines
858 B
Go
Raw Normal View History

2025-03-07 16:26:24 -06:00
package nomino
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestWithOriginal(t *testing.T) {
2025-03-10 14:52:50 -05:00
var c Config
2025-03-07 16:26:24 -06:00
name := "foobar"
WithOriginal(name)(&c)
2025-03-11 16:42:39 -05:00
assert.Equal(t, name, c.original)
2025-03-07 16:26:24 -06:00
}
func TestWithPrefix(t *testing.T) {
2025-03-10 14:52:50 -05:00
var c Config
2025-03-07 16:26:24 -06:00
pref := "draft"
WithPrefix(pref)(&c)
2025-03-11 16:42:39 -05:00
assert.Equal(t, pref, c.prefix)
2025-03-07 16:26:24 -06:00
}
func TestWithSuffix(t *testing.T) {
2025-03-10 14:52:50 -05:00
var c Config
2025-03-07 16:26:24 -06:00
suff := "out"
WithSuffix(suff)(&c)
2025-03-11 16:42:39 -05:00
assert.Equal(t, suff, c.suffix)
2025-03-07 16:26:24 -06:00
}
func TestWithoutExtension(t *testing.T) {
2025-03-10 14:52:50 -05:00
c := Config{extension: ".foobar"}
2025-03-07 16:26:24 -06:00
WithoutExtension()(&c)
assert.Equal(t, "", c.extension)
}
func TestWithExtension(t *testing.T) {
2025-03-10 14:52:50 -05:00
var c Config
2025-03-07 16:26:24 -06:00
ext := "yaml"
WithExtension(ext)(&c)
assert.Equal(t, "."+ext, c.extension)
}
2025-03-11 16:42:39 -05:00
func TestWithSeparator(t *testing.T) {
var c Config
sep := "---"
WithSeparator(sep)(&c)
assert.Equal(t, sep, c.separator)
}