package nomino import ( "testing" "github.com/stretchr/testify/assert" ) func TestSlugMissingFilename(t *testing.T) { conf := NewConfig(WithGenerator(Slug())) st, err := conf.generator(&conf) assert.Zero(t, st) assert.ErrorIs(t, err, ErrMissingOriginal) } func TestSlugRemovesOriginal(t *testing.T) { conf := NewConfig(WithGenerator(Slug()), WithOriginal("Hello, World")) st, err := conf.generator(&conf) assert.Zero(t, conf.original) assert.Equal(t, "hello-world", st) assert.NoError(t, err) } func TestHashBadHash(t *testing.T) { conf := NewConfig(WithOriginal("foobar"), WithGenerator(Hash(0))) st, err := conf.generator(&conf) assert.Equal(t, "", st) assert.ErrorIs(t, err, ErrInvalidHashType) assert.ErrorContains(t, err, "invalid hash type: HashType(0)") } func TestHashMissingOriginal(t *testing.T) { conf := NewConfig(WithGenerator(Hash(HashMD5))) st, err := conf.generator(&conf) assert.Equal(t, "", st) assert.ErrorIs(t, err, ErrMissingOriginal) } func TestHashTypeStringer(t *testing.T) { s := HashMD5.String() assert.Equal(t, "MD5", s) }