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,62 @@
|
||||
package model
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPendingInvitationStatusValues(t *testing.T) {
|
||||
got := PendingInvitationStatusValues()
|
||||
want := []string{"created", "sent"}
|
||||
if len(got) != len(want) {
|
||||
t.Fatalf("pending status count mismatch: got %d want %d", len(got), len(want))
|
||||
}
|
||||
for i := range want {
|
||||
if got[i] != want[i] {
|
||||
t.Fatalf("pending status %d mismatch: got %q want %q", i, got[i], want[i])
|
||||
}
|
||||
}
|
||||
|
||||
if !IsPendingInvitationStatus(InvitationCreated) {
|
||||
t.Fatal("created must be pending")
|
||||
}
|
||||
if !IsPendingInvitationStatus(InvitationSent) {
|
||||
t.Fatal("sent must be pending")
|
||||
}
|
||||
for _, status := range []InvitationStatus{InvitationAccepted, InvitationDeclined, InvitationRevoked} {
|
||||
if IsPendingInvitationStatus(status) {
|
||||
t.Fatalf("%q must not be pending", status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvitationValidateEmail(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
email string
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "valid", email: "invitee@example.com"},
|
||||
{name: "whitespace padded valid", email: " invitee@example.com "},
|
||||
{name: "empty", email: "", wantErr: true},
|
||||
{name: "whitespace only", email: " ", wantErr: true},
|
||||
{name: "missing domain", email: "invitee@", wantErr: true},
|
||||
{name: "missing at", email: "invitee.example.com", wantErr: true},
|
||||
{name: "display name", email: "Invitee <invitee@example.com>", wantErr: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
inv := &Invitation{
|
||||
Status: InvitationCreated,
|
||||
Content: invitationDesc{
|
||||
Email: tt.email,
|
||||
},
|
||||
}
|
||||
err := inv.Validate()
|
||||
if tt.wantErr && err == nil {
|
||||
t.Fatal("expected validation error")
|
||||
}
|
||||
if !tt.wantErr && err != nil {
|
||||
t.Fatalf("expected valid invitation, got %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user