nomino/config_test.go

32 lines
700 B
Go
Raw Normal View History

2025-03-10 14:52:50 -05:00
package nomino
import (
"testing"
"github.com/google/uuid"
"github.com/nalgeon/be"
2025-03-10 14:52:50 -05:00
)
func TestNewConf(t *testing.T) {
c := NewConfig()
be.Equal(t, c.extension, ".txt")
2025-03-13 15:36:30 -05:00
st, _ := c.generator(&c)
2025-03-10 14:52:50 -05:00
_, parseErr := uuid.Parse(st)
be.Err(t, parseErr, nil)
2025-03-10 14:52:50 -05:00
}
func TestNewConfWithOpts(t *testing.T) {
c := NewConfig(WithoutExtension(), WithPrefix("foobar"))
be.Equal(t, c.extension, "")
be.Equal(t, c.prefix, "foobar")
2025-03-10 14:52:50 -05:00
}
func TestConfAddOpts(t *testing.T) {
c := Config{original: "hi"}
c2 := c.AddOptions(WithOriginalSlug("Hello, my dear"), WithPrefix("yo"))
be.Equal(t, c.prefix, "")
be.Equal(t, c.original, "hi")
be.Equal(t, c2.original, "hello-my-dear")
be.Equal(t, c2.prefix, "yo")
}