Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jondot committed Oct 31, 2024
1 parent e838a4d commit 62698ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions examples/demo/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ impl Hooks for App {
}

// <snip id="app-initializers">
async fn initializers(ctx: &AppContext) -> Result<Vec<Box<dyn Initializer>>> {
let mut initializers: Vec<Box<dyn Initializer>> = vec![
async fn initializers(_ctx: &AppContext) -> Result<Vec<Box<dyn Initializer>>> {
let initializers: Vec<Box<dyn Initializer>> = vec![
Box::new(initializers::axum_session::AxumSessionInitializer),
Box::new(initializers::view_engine::ViewEngineInitializer),
Box::new(initializers::hello_view_engine::HelloViewEngineInitializer),
Expand Down
9 changes: 4 additions & 5 deletions examples/demo/tests/requests/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use insta::{assert_debug_snapshot, with_settings};
use loco_rs::testing;
use rstest::rstest;
use sea_orm::entity::prelude::*;
use serde_json;
use serial_test::serial;

// TODO: see how to dedup / extract this to app-local test utils
Expand Down Expand Up @@ -34,7 +33,7 @@ async fn can_get_notes(#[case] test_name: &str, #[case] params: serde_json::Valu

with_settings!({
filters => {
let mut combined_filters = testing::CLEANUP_DATE.to_vec();
let mut combined_filters = testing::get_cleanup_date().clone();
combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]);
combined_filters
}
Expand Down Expand Up @@ -62,7 +61,7 @@ async fn can_add_note() {

with_settings!({
filters => {
let mut combined_filters = testing::CLEANUP_DATE.to_vec();
let mut combined_filters = testing::get_cleanup_date().clone();
combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]);
combined_filters
}
Expand All @@ -87,7 +86,7 @@ async fn can_get_note() {

with_settings!({
filters => {
let mut combined_filters = testing::CLEANUP_DATE.to_vec();
let mut combined_filters = testing::get_cleanup_date().clone();
combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]);
combined_filters
}
Expand All @@ -113,7 +112,7 @@ async fn can_delete_note() {

with_settings!({
filters => {
let mut combined_filters = testing::CLEANUP_DATE.to_vec();
let mut combined_filters = testing::get_cleanup_date().clone();
combined_filters.extend(vec![(r#"\"id\\":\d+"#, r#""id\":ID"#)]);
combined_filters
}
Expand Down
16 changes: 8 additions & 8 deletions src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ use crate::{
Result,
};

pub static CLEANUP_USER_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
pub static CLEANUP_DATE: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
pub static CLEANUP_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
pub static CLEANUP_MAIL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_USER_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_DATE: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_MODEL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();
static CLEANUP_MAIL: OnceLock<Vec<(&'static str, &'static str)>> = OnceLock::new();

fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> {
pub fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> {
CLEANUP_USER_MODEL.get_or_init(|| {
vec![
(
Expand All @@ -35,7 +35,7 @@ fn get_cleanup_user_model() -> &'static Vec<(&'static str, &'static str)> {
})
}

fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> {
pub fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> {
CLEANUP_DATE.get_or_init(|| {
vec![
(
Expand All @@ -48,11 +48,11 @@ fn get_cleanup_date() -> &'static Vec<(&'static str, &'static str)> {
})
}

fn get_cleanup_model() -> &'static Vec<(&'static str, &'static str)> {
pub fn get_cleanup_model() -> &'static Vec<(&'static str, &'static str)> {
CLEANUP_MODEL.get_or_init(|| vec![(r"id: \d+,", "id: ID")])
}

fn get_cleanup_mail() -> &'static Vec<(&'static str, &'static str)> {
pub fn get_cleanup_mail() -> &'static Vec<(&'static str, &'static str)> {
CLEANUP_MAIL.get_or_init(|| {
vec![
(r"[0-9A-Za-z]+{40}", "IDENTIFIER"),
Expand Down

0 comments on commit 62698ac

Please sign in to comment.