feat: actually send email
This commit is contained in:
parent
6dfc9a0f3e
commit
0427df8656
3 changed files with 51 additions and 12 deletions
|
|
@ -4,6 +4,7 @@ use learn_axum::telemetry::{get_subscriber, init_subscriber};
|
|||
use once_cell::sync::Lazy;
|
||||
use sqlx::{Connection, Executor, PgConnection, PgPool};
|
||||
use uuid::Uuid;
|
||||
use wiremock::MockServer;
|
||||
|
||||
/// Ensure that the `tracing` stack is only initialised once using `once_cell`
|
||||
static TRACING: Lazy<()> = Lazy::new(|| {
|
||||
|
|
@ -25,6 +26,7 @@ static TRACING: Lazy<()> = Lazy::new(|| {
|
|||
pub struct TestApp {
|
||||
pub address: String,
|
||||
pub db_pool: PgPool,
|
||||
pub email_server: MockServer,
|
||||
}
|
||||
|
||||
impl TestApp {
|
||||
|
|
@ -51,9 +53,8 @@ pub async fn spawn_app() -> TestApp {
|
|||
// All other invocations will instead skip execution.
|
||||
Lazy::force(&TRACING);
|
||||
|
||||
// TODO:
|
||||
// // Launch a mock server to stand in for Postmark's API
|
||||
// let email_server = MockServer::start().await;
|
||||
// Launch a mock server to stand in for Postmark's API
|
||||
let email_server = MockServer::start().await;
|
||||
|
||||
// Randomise configuration to ensure test isolation
|
||||
let configuration = {
|
||||
|
|
@ -62,6 +63,8 @@ pub async fn spawn_app() -> TestApp {
|
|||
c.database.name = Uuid::new_v4().to_string();
|
||||
// Use a random OS port
|
||||
c.application.port = 0;
|
||||
// Use the mock server as email API
|
||||
c.email_client.base_url = email_server.uri();
|
||||
c
|
||||
};
|
||||
|
||||
|
|
@ -81,7 +84,7 @@ pub async fn spawn_app() -> TestApp {
|
|||
address,
|
||||
// port: application_port,
|
||||
db_pool: connection_pool,
|
||||
// email_server,
|
||||
email_server,
|
||||
// test_user: TestUser::generate(),
|
||||
// api_client: client,
|
||||
// email_client: configuration.email_client.client(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue