23 lines
560 B
Go
23 lines
560 B
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func Test_Link_NormaliseName(t *testing.T) {
|
|
link := Link{
|
|
Name: "!c@o#o$l%-^a&w*e(s)o_m=e+-[l{i]n}k-0123456789ABCDEF",
|
|
}
|
|
|
|
want := "cool-awesome-link-0123456789abcdef"
|
|
got := link.NormaliseName()
|
|
if want != got {
|
|
t.Errorf(`name with invalid characters not properly formatted (want "%s", got "%s")`, want, got)
|
|
}
|
|
|
|
link.Name = want
|
|
got = link.NormaliseName()
|
|
if want != got {
|
|
t.Errorf(`valid name mangled by formatter (want "%s", got "%s")`, want, got)
|
|
}
|
|
}
|