Error handling with thiserror and anyhow
This commit is contained in:
@@ -122,3 +122,19 @@ async fn subscribe_sends_a_confirmation_email_with_a_link() {
|
||||
let confirmation_links = app.get_confirmation_links(email_request);
|
||||
assert_eq!(confirmation_links.html, confirmation_links.text);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_fails_if_there_is_a_fatal_database_error() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let body = "name=Alphonse&email=alphonse.paix%40outlook.com";
|
||||
|
||||
sqlx::query!("ALTER TABLE subscriptions DROP COLUMN email")
|
||||
.execute(&app.connection_pool)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let response = app.post_subscriptions(body.into()).await;
|
||||
|
||||
assert_eq!(response.status().as_u16(), 500);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user