test alias regex

This commit is contained in:
Carlosokumu 2025-01-21 13:16:14 +03:00
parent 3e859d3469
commit b4cd696f48
Signed by: carlos
GPG Key ID: 7BD6BC8160A5C953

41
identity/alias_test.go Normal file
View File

@ -0,0 +1,41 @@
package identity
import (
"testing"
)
func TestAliasesRegext(t *testing.T) {
tests := []struct {
alias string
isValid bool
}{
{
alias: "foobar",
isValid: true,
},
{
alias: "foo.sarafu.local",
isValid: true,
},
{
alias: "foo.sarafu",
isValid: true,
},
{
alias: "foo.",
isValid: false,
},
{
alias: ".foo..bar",
isValid: false,
},
}
for _, tt := range tests {
t.Run(tt.alias, func(t *testing.T) {
isValid := IsValidAlias(tt.alias)
if isValid != tt.isValid {
t.Fatalf("expected %v, got %v", tt.isValid, isValid)
}
})
}
}