feat(test): connecting to PostgreSQL

- rename the database name in the configuration.yaml
This commit is contained in:
2024-05-03 17:10:39 -04:00
parent 38f9646526
commit 46ac102adc
3 changed files with 21 additions and 1 deletions

View File

@@ -2,10 +2,21 @@ mod test_utils;
use test_utils::spawn_app;
use email_newsletter_api::configuration::{self, get_configuration};
use sqlx::{Connection, PgConnection};
#[tokio::test]
async fn subscribe_returns_a_200_for_valid_form_data() {
let server_address = spawn_app();
let configuration = get_configuration().expect("Failed to read configuration");
let postgres_connection_string = configuration.database.connection_string();
let connection = PgConnection::connect(&postgres_connection_string)
.await
.expect("Failed to connect to Postgres");
let client = reqwest::Client::new();
let body = "name=le%20test&email=le_test%40gmail.com";