Fix incorrect database query in test suite
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use secrecy::ExposeSecret;
|
||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||
use sqlx::{Executor, PgPool};
|
||||
use tokio::net::TcpListener;
|
||||
use uuid::Uuid;
|
||||
use zero2prod::{
|
||||
@@ -39,11 +39,6 @@ async fn health_check_works() {
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_200_for_valid_form_data() {
|
||||
let app = spawn_app().await;
|
||||
let configuration = get_configuration().expect("Failed to read configuration");
|
||||
let connection_string = configuration.database.connection_string();
|
||||
let mut connection = PgConnection::connect(connection_string.expose_secret())
|
||||
.await
|
||||
.expect("Failed to connect to Postgres");
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let body = "name=alphonse&email=alphonse.paix%40outlook.com";
|
||||
@@ -58,7 +53,7 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
|
||||
assert_eq!(200, response.status().as_u16());
|
||||
|
||||
let saved = sqlx::query!("SELECT email, name FROM subscriptions")
|
||||
.fetch_one(&mut connection)
|
||||
.fetch_one(&app.connection_pool)
|
||||
.await
|
||||
.expect("Failed to fetch saved subscription");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user