fix: add valid test identified by linter

This commit is contained in:
Adrien Raffin-Caboisse 2022-02-23 14:28:20 +01:00
parent 046116656b
commit ae6a20e4d9
No known key found for this signature in database
GPG Key ID: 7FB60532DEBEAD6A
2 changed files with 12 additions and 3 deletions

View File

@ -271,9 +271,9 @@ func (n *Namespace) toProto() *v1.Namespace {
func NormalizeNamespaceName(name string, stripEmailDomain bool) (string, error) {
name = strings.ToLower(name)
name = strings.ReplaceAll(name, "'", "")
if stripEmailDomain {
idx := strings.Index(name, "@")
name = name[:idx]
atIdx := strings.Index(name, "@")
if stripEmailDomain && atIdx > 0 {
name = name[:atIdx]
} else {
name = strings.ReplaceAll(name, "@", ".")
}

View File

@ -280,6 +280,15 @@ func TestNormalizeNamespaceName(t *testing.T) {
want: "foo.bar",
wantErr: false,
},
{
name: "strip enabled no email passed as argument",
args: args{
name: "not-email-and-strip-enabled",
stripEmailDomain: true,
},
want: "not-email-and-strip-enabled",
wantErr: false,
},
{
name: "normalize complex email",
args: args{