Tests update
This commit is contained in:
@@ -58,38 +58,6 @@ async fn subscribe_returns_a_422_when_data_is_missing() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_shows_an_error_message_when_fields_are_present_but_invalid() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let test_cases = [
|
||||
("name=&email=alphonse.paix%40outlook.com", "an empty name"),
|
||||
("name=Alphonse&email=&email_check=", "an empty email"),
|
||||
(
|
||||
"name=Alphonse&email=not-an-email&email_check=not-an_email",
|
||||
"an invalid email",
|
||||
),
|
||||
(
|
||||
"name=Alphonse&email=alphonse.paix@outlook.com&email_check=alphonse.paix@outlook.fr",
|
||||
"two different email addresses",
|
||||
),
|
||||
];
|
||||
for (body, description) in test_cases {
|
||||
let response_text = app
|
||||
.post_subscriptions(body.into())
|
||||
.await
|
||||
.text()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(
|
||||
!response_text.contains("Your account has been confirmed"),
|
||||
"the API did not displayed an error message when the payload had an {}.",
|
||||
description
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_sends_a_confirmation_email_for_valid_data() {
|
||||
let app = TestApp::spawn().await;
|
||||
@@ -131,7 +99,7 @@ async fn subscribe_fails_if_there_is_a_fatal_database_error() {
|
||||
let app = TestApp::spawn().await;
|
||||
|
||||
let email = "alphonse.paix@outlook.com";
|
||||
let body = format!("name=Alphonse&email={0}&email_check={0}", email);
|
||||
let body = format!("name=Alphonse&email={}", email);
|
||||
|
||||
sqlx::query!("ALTER TABLE subscriptions DROP COLUMN email")
|
||||
.execute(&app.connection_pool)
|
||||
|
||||
Reference in New Issue
Block a user