Split test cases.

This commit is contained in:
LukeMathWalker 2021-03-08 23:02:45 +00:00
parent 123e7f139c
commit 28fc5612ae

View file

@ -23,6 +23,25 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
assert_eq!(saved.name, "le guin");
}
#[actix_rt::test]
async fn subscribe_persists_the_new_subscriber() {
// Arrange
let app = spawn_app().await;
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
// Act
let response = app.post_subscriptions(body.into()).await;
// Assert
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]
async fn subscribe_sends_a_confirmation_email_for_valid_data() {
// Arrange