32 lines
1000 B
Go
32 lines
1000 B
Go
package httpapi
|
|||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestInviteMailResult(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
cases := []struct {
|
||
|
|
name string
|
||
|
|
smtpEnabled bool
|
||
|
|
sendOK bool
|
||
|
|
wantMailSent bool
|
||
|
|
wantToken bool
|
||
|
|
}{
|
||
|
|
{name: "smtp_ok", smtpEnabled: true, sendOK: true, wantMailSent: true, wantToken: false},
|
||
|
|
{name: "smtp_send_fail", smtpEnabled: true, sendOK: false, wantMailSent: false, wantToken: true},
|
||
|
|
{name: "noop_mailer_send_ok", smtpEnabled: false, sendOK: true, wantMailSent: false, wantToken: true},
|
||
|
|
{name: "disabled_no_send", smtpEnabled: false, sendOK: false, wantMailSent: false, wantToken: true},
|
||
|
|
}
|
||
|
|
for _, tc := range cases {
|
||
|
|
t.Run(tc.name, func(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
mailSent, includeToken := inviteMailResult(tc.smtpEnabled, tc.sendOK)
|
||
|
|
if mailSent != tc.wantMailSent {
|
||
|
|
t.Fatalf("mailSent=%v want %v", mailSent, tc.wantMailSent)
|
||
|
|
}
|
||
|
|
if includeToken != tc.wantToken {
|
||
|
|
t.Fatalf("includeToken=%v want %v", includeToken, tc.wantToken)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|