mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2025-01-05 14:49:01 +00:00
Return 500 if email delivery fails.
This commit is contained in:
parent
17ec08037f
commit
de05b2d1a8
2 changed files with 9 additions and 2 deletions
|
@ -59,13 +59,14 @@ pub async fn subscribe(
|
||||||
.commit()
|
.commit()
|
||||||
.await
|
.await
|
||||||
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||||
let _ = send_confirmation_email(
|
send_confirmation_email(
|
||||||
&email_client,
|
&email_client,
|
||||||
new_subscriber,
|
new_subscriber,
|
||||||
&base_url.0,
|
&base_url.0,
|
||||||
&subscription_token,
|
&subscription_token,
|
||||||
)
|
)
|
||||||
.await;
|
.await
|
||||||
|
.map_err(|_| HttpResponse::InternalServerError().finish())?;
|
||||||
Ok(HttpResponse::Ok().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 app = spawn_app().await;
|
||||||
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
|
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
|
// Act
|
||||||
let response = app.post_subscriptions(body.into()).await;
|
let response = app.post_subscriptions(body.into()).await;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue