feat: actually send email
This commit is contained in:
parent
6dfc9a0f3e
commit
0427df8656
3 changed files with 51 additions and 12 deletions
|
|
@ -1,4 +1,26 @@
|
|||
use crate::helpers::{spawn_app, TestApp};
|
||||
use crate::helpers::spawn_app;
|
||||
use wiremock::matchers::{method, path};
|
||||
use wiremock::{Mock, ResponseTemplate};
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_sends_a_confirmation_email_for_valid_data() {
|
||||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
|
||||
|
||||
Mock::given(path("/email"))
|
||||
.and(method("POST"))
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
.expect(1)
|
||||
.mount(&app.email_server)
|
||||
.await;
|
||||
|
||||
// Act
|
||||
app.post_subscriptions(body.into()).await;
|
||||
|
||||
// Assert
|
||||
// Mock asserts on drop
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn subscribe_returns_a_422_when_data_is_missing() {
|
||||
|
|
@ -29,6 +51,11 @@ async fn subscribe_returns_a_200_for_valid_form_data() {
|
|||
// Arrange
|
||||
let app = spawn_app().await;
|
||||
let body = "name=le%20guin&email=ursula_le_guin%40gmail.com";
|
||||
Mock::given(path("/email"))
|
||||
.and(method("POST"))
|
||||
.respond_with(ResponseTemplate::new(200))
|
||||
.mount(&app.email_server)
|
||||
.await;
|
||||
|
||||
// Act
|
||||
let response = app.post_subscriptions(body.into()).await;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue