package helpers import ( "testing" ) func TestMakePath(t *testing.T) { tests := []struct { input string expected string }{ {" foo bar ", "foo-bar"}, {"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"}, {"foo,bar:foo%bar", "foobarfoobar"}, {"foo/bar.html", "foo/bar.html"}, {"трям/трям", "трям/трям"}, } for _, test := range tests { output := MakePath(test.input) if output != test.expected { t.Errorf("Expected %#v, got %#v\n", test.expected, output) } } } func TestUrlize(t *testing.T) { tests := []struct { input string expected string }{ {" foo bar ", "foo-bar"}, {"foo.bar/foo_bar-foo", "foo.bar/foo_bar-foo"}, {"foo,bar:foo%bar", "foobarfoobar"}, {"foo/bar.html", "foo/bar.html"}, {"трям/трям", "%D1%82%D1%80%D1%8F%D0%BC/%D1%82%D1%80%D1%8F%D0%BC"}, } for _, test := range tests { output := Urlize(test.input) if output != test.expected { t.Errorf("Expected %#v, got %#v\n", test.expected, output) } } }