package calls import ( "strings" "testing" ) // TestNoMailRefusesOutsideDevelopment is the third boot of CARLOS mail // submission (cmd/calls mail_test.go has the other two): with neither // channel, cmd/calls passes a nil Mailer, and resolve refuses anywhere // but development, naming both ways to fix it. func TestNoMailRefusesOutsideDevelopment(t *testing.T) { cfg := minimalConfig(t) cfg.Mailer = nil _, err := resolve(cfg) if err == nil { t.Fatal("started with no mail in production") } for _, want := range []string{"CARLOS_MAIL=submit", "CALLS_SMTP_HOST"} { if !strings.Contains(err.Error(), want) { t.Errorf("refusal %q does not name %s", err, want) } } cfg.Env = EnvDevelopment if _, err := resolve(cfg); err != nil { t.Fatalf("development with no mail: %v", err) } }