feat: rewrite render

This commit is contained in:
sh0rez 2020-04-29 16:39:37 +02:00
parent 5fbee517fe
commit 7308eecaf3
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
10 changed files with 352 additions and 198 deletions

44
pkg/slug/slug_test.go Normal file
View file

@ -0,0 +1,44 @@
package slug
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSlug(t *testing.T) {
cases := [][]struct {
in, out string
}{
{
{"foo", "foo"},
{"foo", "foo-1"},
{"foo bar", "foo-bar"},
},
{
{"foo", "foo"},
{"fooCamelCase", "foocamelcase"},
},
{
{"foo", "foo"},
{"foo", "foo-1"},
// {"foo 1", "foo-1-1"}, // these are too rare for Jsonnet
// {"foo 1", "foo-1-2"},
{"foo", "foo-2"},
},
{
{"heading with a - dash", "heading-with-a---dash"},
{"heading with an _ underscore", "heading-with-an-_-underscore"},
{"heading with a period.txt", "heading-with-a-periodtxt"},
{"exchange.bind_headers(exchange, routing [, bindCallback])", "exchangebind_headersexchange-routing--bindcallback"},
},
}
for _, cs := range cases {
s := New()
for _, c := range cs {
assert.Equal(t, c.out, s.Slug(c.in))
}
}
}