Update test suite to drop database automatically when test is successfull
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::helpers::{TestApp, fake_newsletter_body, fake_post_body, when_sending_an_email};
|
||||
use sqlx::PgPool;
|
||||
use wiremock::ResponseTemplate;
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscriber_can_unsubscribe() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscriber_can_unsubscribe(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
app.admin_login().await;
|
||||
|
||||
@@ -46,9 +47,9 @@ async fn subscriber_can_unsubscribe() {
|
||||
app.dispatch_all_pending_emails().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_valid_unsubscribe_link_is_present_in_new_post_email_notifications() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn a_valid_unsubscribe_link_is_present_in_new_post_email_notifications(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
app.admin_login().await;
|
||||
|
||||
@@ -82,9 +83,9 @@ async fn a_valid_unsubscribe_link_is_present_in_new_post_email_notifications() {
|
||||
assert!(record.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn a_valid_unsubscribe_link_is_present_in_standalone_emails() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn a_valid_unsubscribe_link_is_present_in_standalone_emails(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
app.admin_login().await;
|
||||
|
||||
@@ -111,23 +112,19 @@ async fn a_valid_unsubscribe_link_is_present_in_standalone_emails() {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn an_invalid_unsubscribe_token_is_rejected() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn an_invalid_unsubscribe_token_is_rejected(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
|
||||
let response = app.get_unsubscribe_confirm("invalid-token").await;
|
||||
|
||||
// let response = reqwest::get(format!("{}/unsubscribe?token=invalid", app.address))
|
||||
// .await
|
||||
// .unwrap();
|
||||
|
||||
assert_eq!(response.status().as_u16(), 404);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscription_works_after_unsubscribe() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn subscription_works_after_unsubscribe(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
app.create_confirmed_subscriber().await;
|
||||
|
||||
let record = sqlx::query!("SELECT email, unsubscribe_token FROM subscriptions")
|
||||
|
||||
Reference in New Issue
Block a user