mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-11-15 21:21:00 +00:00
Add error test.
This commit is contained in:
parent
c14296a34d
commit
faaffbbd98
1 changed files with 18 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue