mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2025-01-31 19:12:28 +00:00
Refactor.
This commit is contained in:
parent
28fc5612ae
commit
6e049bab9e
1 changed files with 3 additions and 10 deletions
|
@ -13,14 +13,6 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
assert_eq!(200, response.status().as_u16());
|
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]
|
#[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";
|
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
let response = app.post_subscriptions(body.into()).await;
|
app.post_subscriptions(body.into()).await;
|
||||||
|
|
||||||
// Assert
|
// 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)
|
.fetch_one(&app.db_pool)
|
||||||
.await
|
.await
|
||||||
.expect("Failed to fetch saved subscription.");
|
.expect("Failed to fetch saved subscription.");
|
||||||
|
|
||||||
assert_eq!(saved.email, "ursula_le_guin@gmail.com");
|
assert_eq!(saved.email, "ursula_le_guin@gmail.com");
|
||||||
assert_eq!(saved.name, "le guin");
|
assert_eq!(saved.name, "le guin");
|
||||||
|
assert_eq!(saved.status, "pending_confirmation");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
|
Loading…
Reference in a new issue