2015-08-26 16:23:33 +00:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2015-12-30 18:05:54 +00:00
|
|
|
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)
|
|
|
|
}
|
2015-08-26 16:26:20 +00:00
|
|
|
}
|
2015-12-30 18:05:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestNormalizeDisplayName_NormNotRequired(t *testing.T) {
|
2015-08-26 16:26:20 +00:00
|
|
|
|
2015-12-30 18:05:54 +00:00
|
|
|
validNames := []string{
|
|
|
|
"test_name_should_normalize_to_itself@example.com",
|
|
|
|
"test1_name_should_normalize_to_itself@example.com",
|
|
|
|
"UPPERlower0123456789-_,.@example.com",
|
2015-08-26 16:23:33 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 18:05:54 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2015-08-26 16:23:33 +00:00
|
|
|
}
|