45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package aws
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizeDisplayName_NormRequired(t *testing.T) {
|
|
|
|
invalidNames := map[string]string{
|
|
"^#$test name\nshould be normalized)(*": "___test_name_should_be_normalized___",
|
|
"^#$test name1 should be normalized)(*": "___test_name1_should_be_normalized___",
|
|
"^#$test name should be normalized)(*": "___test_name__should_be_normalized___",
|
|
"^#$test name__should be normalized)(*": "___test_name__should_be_normalized___",
|
|
}
|
|
|
|
for k, v := range invalidNames {
|
|
normalizedName := normalizeDisplayName(k)
|
|
if normalizedName != v {
|
|
t.Fatalf(
|
|
"normalizeDisplayName does not normalize AWS name correctly: %s should resolve to %s",
|
|
k,
|
|
normalizedName)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNormalizeDisplayName_NormNotRequired(t *testing.T) {
|
|
|
|
validNames := []string{
|
|
"test_name_should_normalize_to_itself@example.com",
|
|
"test1_name_should_normalize_to_itself@example.com",
|
|
"UPPERlower0123456789-_,.@example.com",
|
|
}
|
|
|
|
for _, n := range validNames {
|
|
normalizedName := normalizeDisplayName(n)
|
|
if normalizedName != n {
|
|
t.Fatalf(
|
|
"normalizeDisplayName erroneously normalizes valid names: expected %s but normalized to %s",
|
|
n,
|
|
normalizedName)
|
|
}
|
|
}
|
|
}
|