Refactor.

This commit is contained in:
LukeMathWalker 2021-03-09 21:12:58 +00:00
parent 28fc5612ae
commit 6e049bab9e

View file

@ -13,14 +13,6 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
// Assert
assert_eq!(200, response.status().as_u16());
let saved = sqlx::query!("SELECT email, name FROM subscriptions",)
.fetch_one(&app.db_pool)
.await
.expect("Failed to fetch saved subscription.");
assert_eq!(saved.email, "ursula_le_guin@gmail.com");
assert_eq!(saved.name, "le guin");
}
#[actix_rt::test]
@ -30,16 +22,17 @@ async fn subscribe_persists_the_new_subscriber() {
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
// Act
let response = app.post_subscriptions(body.into()).await;
app.post_subscriptions(body.into()).await;
// Assert
let saved = sqlx::query!("SELECT email, name FROM subscriptions",)
let saved = sqlx::query!("SELECT email, name, status FROM subscriptions",)
.fetch_one(&app.db_pool)
.await
.expect("Failed to fetch saved subscription.");
assert_eq!(saved.email, "ursula_le_guin@gmail.com");
assert_eq!(saved.name, "le guin");
assert_eq!(saved.status, "pending_confirmation");
}
#[actix_rt::test]