Some checks failed
cache-seeder / prune (push) Has been skipped
cache-seeder / frontend (push) Failing after 3s
cache-seeder / python (push) Failing after 3s
cache-seeder / gobuild (push) Failing after 4s
cache-seeder / lint (bindata, lint-backend) (push) Failing after 3s
giteabot backport / giteabot (push) Has been skipped
giteabot / giteabot (push) Has been skipped
cache-prune / prune (push) Has been skipped
release-nightly-snapcraft / build-and-publish (ubuntu-24.04) (push) Has been cancelled
release-nightly-snapcraft / build-and-publish (ubuntu-24.04-arm) (push) Has been cancelled
release-nightly / nightly-binary (push) Has been cancelled
release-nightly / nightly-container (push) Has been cancelled
cron-renovate / cron-renovate (push) Has been skipped
31 lines
776 B
Go
31 lines
776 B
Go
// Copyright 2025 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package sender
|
|
|
|
import "testing"
|
|
|
|
func TestSanitizeEmailAddress(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
expected string
|
|
hasError bool
|
|
}{
|
|
{"abc@gitea.com", "abc@gitea.com", false},
|
|
{"<abc@gitea.com>", "abc@gitea.com", false},
|
|
{"ssss.com", "", true},
|
|
{"<invalid-email>", "", true},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
result, err := sanitizeEmailAddress(tt.input)
|
|
if (err != nil) != tt.hasError {
|
|
t.Errorf("sanitizeEmailAddress(%q) unexpected error status: got %v, want error: %v", tt.input, err != nil, tt.hasError)
|
|
continue
|
|
}
|
|
if result != tt.expected {
|
|
t.Errorf("sanitizeEmailAddress(%q) = %q; want %q", tt.input, result, tt.expected)
|
|
}
|
|
}
|
|
}
|