Update test suite to drop database automatically when test is successfull
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::helpers::{TestApp, when_sending_an_email};
|
||||
use sqlx::PgPool;
|
||||
use wiremock::ResponseTemplate;
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_displays_a_confirmation_message_for_valid_form_data() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_displays_a_confirmation_message_for_valid_form_data(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
when_sending_an_email()
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
@@ -19,9 +20,9 @@ async fn subscribe_displays_a_confirmation_message_for_valid_form_data() {
|
||||
assert!(html_fragment.contains("You'll receive a confirmation email shortly"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_persists_the_new_subscriber() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_persists_the_new_subscriber(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
when_sending_an_email()
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
@@ -45,9 +46,9 @@ async fn subscribe_persists_the_new_subscriber() {
|
||||
assert_eq!(saved.status, "pending_confirmation");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_422_when_data_is_missing() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_returns_a_422_when_data_is_missing(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let response = app.post_subscriptions(String::new()).await;
|
||||
|
||||
@@ -58,9 +59,9 @@ async fn subscribe_returns_a_422_when_data_is_missing() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_sends_a_confirmation_email_for_valid_data() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_sends_a_confirmation_email_for_valid_data(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("email={email}");
|
||||
@@ -74,9 +75,9 @@ async fn subscribe_sends_a_confirmation_email_for_valid_data() {
|
||||
app.post_subscriptions(body).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_sends_a_confirmation_email_with_a_link() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_sends_a_confirmation_email_with_a_link(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("email={email}");
|
||||
@@ -94,9 +95,9 @@ async fn subscribe_sends_a_confirmation_email_with_a_link() {
|
||||
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;
|
||||
#[sqlx::test]
|
||||
async fn subscribe_fails_if_there_is_a_fatal_database_error(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("name=Alphonse&email={}", email);
|
||||
|
||||
Reference in New Issue
Block a user