Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,52 @@
|
||||
package merrors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSignupEmailPolicyError(t *testing.T) {
|
||||
err := SignupEmailPolicyRejected(SignupEmailPolicyReasonFreeDomain, "gmail.com")
|
||||
policyErr, ok := AsSignupEmailPolicyError(err)
|
||||
if !ok {
|
||||
t.Fatalf("expected signup email policy error")
|
||||
}
|
||||
if policyErr.Reason() != SignupEmailPolicyReasonFreeDomain {
|
||||
t.Fatalf("reason mismatch: got=%q", policyErr.Reason())
|
||||
}
|
||||
if policyErr.Domain() != "gmail.com" {
|
||||
t.Fatalf("domain mismatch: got=%q", policyErr.Domain())
|
||||
}
|
||||
if !errors.Is(err, ErrSignupEmailPolicyRejected) {
|
||||
t.Fatalf("expected signup email policy sentinel")
|
||||
}
|
||||
|
||||
reason, ok := Reason(err)
|
||||
if !ok {
|
||||
t.Fatalf("expected generic reason")
|
||||
}
|
||||
if reason != SignupEmailPolicyReasonFreeDomain {
|
||||
t.Fatalf("generic reason mismatch: got=%q", reason)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignupEmailPolicyReasonNormalization(t *testing.T) {
|
||||
for _, reason := range []string{
|
||||
SignupEmailPolicyReasonInvalidEmail,
|
||||
SignupEmailPolicyReasonDisposableDomain,
|
||||
SignupEmailPolicyReasonFreeDomain,
|
||||
} {
|
||||
if !IsSignupEmailPolicyReason(reason) {
|
||||
t.Fatalf("expected supported reason: %q", reason)
|
||||
}
|
||||
}
|
||||
|
||||
err := SignupEmailPolicyRejected("unexpected_reason", "")
|
||||
policyErr, ok := AsSignupEmailPolicyError(err)
|
||||
if !ok {
|
||||
t.Fatalf("expected signup email policy error")
|
||||
}
|
||||
if policyErr.Reason() != SignupEmailPolicyReasonInvalidEmail {
|
||||
t.Fatalf("unexpected reasons must not leak: got=%q", policyErr.Reason())
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user