diff --git a/identity/alias_test.go b/identity/alias_test.go new file mode 100644 index 0000000..cc712bd --- /dev/null +++ b/identity/alias_test.go @@ -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) + } + }) + } +}