Add error test.

This commit is contained in:
LukeMathWalker 2021-05-02 17:02:18 +01:00
parent c14296a34d
commit faaffbbd98

View file

@ -41,6 +41,24 @@ async fn subscribe_persists_the_new_subscriber() {
assert_eq!(saved.status, "pending_confirmation");
}
#[actix_rt::test]
async fn subscribe_fails_if_there_is_a_fatal_database_error() {
// Arrange
let app = spawn_app().await;
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
// Sabotage the database
sqlx::query!("ALTER TABLE subscription_tokens DROP COLUMN subscription_token;",)
.execute(&app.db_pool)
.await
.unwrap();
// Act
let response = app.post_subscriptions(body.into()).await;
// Assert
assert_eq!(response.status().as_u16(), 500);
}
#[actix_rt::test]
async fn subscribe_sends_a_confirmation_email_for_valid_data() {
// Arrange