tests: remove hidden couplings

This commit is contained in:
Sandro Eiler 2024-03-04 11:48:47 +01:00
parent ebd7755731
commit fe5a596265
3 changed files with 27 additions and 35 deletions

View file

@ -27,6 +27,25 @@ pub struct TestApp {
pub db_pool: PgPool,
}
impl TestApp {
pub async fn get_health_check(&self) -> reqwest::Response {
reqwest::Client::new()
.get(&format!("{}/health_check", &self.address))
.send()
.await
.expect("Failed to execute request.")
}
pub async fn post_subscriptions(&self, body: String) -> reqwest::Response {
reqwest::Client::new()
.post(&format!("{}/subscriptions", &self.address))
.header("Content-Type", "application/x-www-form-urlencoded")
.body(body)
.send()
.await
.expect("Failed to execute request.")
}
}
pub async fn spawn_app() -> TestApp {
// The first time `initialize` is invoked the code in `TRACING` is executed.
// All other invocations will instead skip execution.
@ -60,7 +79,6 @@ pub async fn spawn_app() -> TestApp {
TestApp {
address,
// address: format!("http://localhost:{}", application_port),
// port: application_port,
db_pool: connection_pool,
// email_server,