Update test suite to drop database automatically when test is successfull
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
use crate::helpers::{TestApp, assert_is_redirect_to};
|
||||
use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tokio::test]
|
||||
async fn you_must_be_logged_in_to_change_your_password() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn you_must_be_logged_in_to_change_your_password(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let new_password = Uuid::new_v4().to_string();
|
||||
let response = app
|
||||
@@ -17,9 +18,9 @@ async fn you_must_be_logged_in_to_change_your_password() {
|
||||
assert_is_redirect_to(&response, "/login");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn new_password_fields_must_match() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn new_password_fields_must_match(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
app.post_login(&serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
@@ -42,9 +43,9 @@ async fn new_password_fields_must_match() {
|
||||
assert!(html_fragment.contains("You entered two different passwords"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn current_password_is_invalid() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn current_password_is_invalid(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
app.post_login(&serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
@@ -66,9 +67,9 @@ async fn current_password_is_invalid() {
|
||||
assert!(html_fragment.contains("The current password is incorrect"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn changing_password_works() {
|
||||
let app = TestApp::spawn().await;
|
||||
#[sqlx::test]
|
||||
async fn changing_password_works(connection_pool: PgPool) {
|
||||
let app = TestApp::spawn(connection_pool).await;
|
||||
|
||||
let login_body = &serde_json::json!({
|
||||
"username": app.test_user.username,
|
||||
|
||||
Reference in New Issue
Block a user