refactor: fix some code.

This commit is contained in:
Fernandez Ludovic 2017-12-04 20:04:08 +01:00 committed by Traefiker
parent 07524f5c99
commit 0472d19bd4
15 changed files with 71 additions and 15 deletions

View file

@ -464,6 +464,45 @@ func TestBaseProvider_GetConfiguration(t *testing.T) {
}
}
func TestNormalize(t *testing.T) {
testCases := []struct {
desc string
name string
expected string
}{
{
desc: "without special chars",
name: "foobar",
expected: "foobar",
},
{
desc: "with special chars",
name: "foo.foo.foo;foo:foo!foo/foo\\foo)foo_123-ç_àéè",
expected: "foo-foo-foo-foo-foo-foo-foo-foo-foo-123-ç-àéè",
},
{
desc: "starts with special chars",
name: ".foo.foo",
expected: "foo-foo",
},
{
desc: "ends with special chars",
name: "foo.foo.",
expected: "foo-foo",
},
}
for _, test := range testCases {
test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
actual := Normalize(test.name)
assert.Equal(t, test.expected, actual)
})
}
}
func readTemplateFile(t *testing.T, path string) string {
t.Helper()
expectedContent, err := ioutil.ReadFile(path)