mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-15 21:21:00 +00:00
Return 500 if email delivery fails.
This commit is contained in:
parent
80aa2a4575
commit
b778d9f6e2
2 changed files with 9 additions and 2 deletions
|
@ -59,13 +59,14 @@ pub async fn subscribe(
|
|||
.commit()
|
||||
.await
|
||||
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||
let _ = send_confirmation_email(
|
||||
send_confirmation_email(
|
||||
&email_client,
|
||||
new_subscriber,
|
||||
&base_url.0,
|
||||
&subscription_token,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,12 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
|
|||
let app = spawn_app().await;
|
||||
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
|
||||
|
||||
Mock::given(path("/email"))
|
||||
.and(method("POST"))
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
.mount(&app.email_server)
|
||||
.await;
|
||||
|
||||
// Act
|
||||
let response = app.post_subscriptions(body.into()).await;
|
||||
|
||||
|
|
Loading…
Reference in a new issue