databricks-cli/libs/textutil/textutil_test.go

59 lines
898 B
Go

package textutil
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNormalizeString(t *testing.T) {
cases := []struct {
input string
expected string
}{
{
input: "test",
expected: "test",
},
{
input: "test test",
expected: "test_test",
},
{
input: "test-test",
expected: "test_test",
},
{
input: "test_test",
expected: "test_test",
},
{
input: "test.test",
expected: "test_test",
},
{
input: "test/test",
expected: "test_test",
},
{
input: "test/test.test",
expected: "test_test_test",
},
{
input: "TestTest",
expected: "testtest",
},
{
input: "TestTestTest",
expected: "testtesttest",
},
{
input: ".test//test..test",
expected: "test_test_test",
}}
for _, c := range cases {
assert.Equal(t, c.expected, NormalizeString(c.input))
}
}