Cargo fmt.

This commit is contained in:
LukeMathWalker 2021-04-02 11:50:59 +01:00
parent 0de778e218
commit 055980b975
4 changed files with 15 additions and 14 deletions

View file

@ -5,7 +5,7 @@ use actix_web::{web, HttpResponse};
use chrono::Utc;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use sqlx::{PgPool, Transaction, Postgres};
use sqlx::{PgPool, Postgres, Transaction};
use std::convert::TryInto;
use uuid::Uuid;
@ -43,7 +43,10 @@ pub async fn subscribe(
.0
.try_into()
.map_err(|_| HttpResponse::BadRequest().finish())?;
let mut transaction = pool.begin().await.map_err(|_| HttpResponse::InternalServerError().finish())?;
let mut transaction = pool
.begin()
.await
.map_err(|_| HttpResponse::InternalServerError().finish())?;
let subscriber_id = insert_subscriber(&mut transaction, &new_subscriber)
.await
.map_err(|_| HttpResponse::InternalServerError().finish())?;
@ -52,7 +55,10 @@ pub async fn subscribe(
store_token(&mut transaction, subscriber_id, &subscription_token)
.await
.map_err(|_| HttpResponse::InternalServerError().finish())?;
transaction.commit().await.map_err(|_| HttpResponse::InternalServerError().finish())?;
transaction
.commit()
.await
.map_err(|_| HttpResponse::InternalServerError().finish())?;
let _ = send_confirmation_email(
&email_client,
new_subscriber,

View file

@ -1,6 +1,6 @@
use crate::configuration::{DatabaseSettings, Settings};
use crate::email_client::EmailClient;
use crate::routes::{health_check, subscribe, confirm};
use crate::routes::{confirm, health_check, subscribe};
use actix_web::dev::Server;
use actix_web::web::Data;
use actix_web::{web, App, HttpServer};

View file

@ -24,7 +24,7 @@ pub struct TestApp {
/// Confirmation links embedded in the request to the email API.
pub struct ConfirmationLinks {
pub html: reqwest::Url,
pub plain_text: reqwest::Url
pub plain_text: reqwest::Url,
}
impl TestApp {
@ -59,10 +59,7 @@ impl TestApp {
let html = get_link(&body["HtmlBody"].as_str().unwrap());
let plain_text = get_link(&body["TextBody"].as_str().unwrap());
ConfirmationLinks {
html,
plain_text
}
ConfirmationLinks { html, plain_text }
}
}

View file

@ -1,6 +1,6 @@
use crate::helpers::spawn_app;
use wiremock::{ResponseTemplate, Mock};
use wiremock::matchers::{path, method};
use wiremock::matchers::{method, path};
use wiremock::{Mock, ResponseTemplate};
#[actix_rt::test]
async fn confirmations_without_token_are_rejected_with_a_400() {
@ -33,9 +33,7 @@ async fn the_link_returned_by_subscribe_returns_a_200_if_called() {
let confirmation_links = app.get_confirmation_links(&email_request);
// Act
let response = reqwest::get(confirmation_links.html)
.await
.unwrap();
let response = reqwest::get(confirmation_links.html).await.unwrap();
// Assert
assert_eq!(response.status().as_u16(), 200);