From f14543af6b8c0bf7de1eab28422fc59d47243932 Mon Sep 17 00:00:00 2001 From: Martin Berg Alstad Date: Sat, 8 Mar 2025 19:09:43 +0100 Subject: [PATCH] :recycle: Removed Makefile, refactored schema in tests --- Cargo.toml | 2 +- Makefile.toml | 15 --------------- crates/tests/diesel.toml | 2 +- crates/tests/tests/diesel_crud_derive.rs | 14 ++++---------- crates/tests/tests/schema.rs | 6 ++++++ justfile | 4 ++-- src/diesel/migration.rs | 3 +-- 7 files changed, 15 insertions(+), 31 deletions(-) delete mode 100644 Makefile.toml create mode 100644 crates/tests/tests/schema.rs diff --git a/Cargo.toml b/Cargo.toml index f6bb82a..c248758 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ exclude = ["examples"] edition = "2024" rust-version = "1.85" authors = ["Martin Berg Alstad"] -homepage = "emberal.github.io" +homepage = "martials.no" [package] name = "lib" diff --git a/Makefile.toml b/Makefile.toml deleted file mode 100644 index 0e2175a..0000000 --- a/Makefile.toml +++ /dev/null @@ -1,15 +0,0 @@ -[tasks.clippy] -command = "cargo" -args = ["clippy", "--all-targets", "--all-features", "--", "-D", "warnings"] - -[tasks.fmt] -command = "cargo" -args = ["fmt", "--all"] - -[tasks.test] -command = "cargo" -args = ["test", "--all-features"] - -[tasks.coverage] -command = "cargo" -args = ["llvm-cov", "--all-features"] diff --git a/crates/tests/diesel.toml b/crates/tests/diesel.toml index 83d15a9..aac20c1 100644 --- a/crates/tests/diesel.toml +++ b/crates/tests/diesel.toml @@ -2,7 +2,7 @@ # see https://diesel.rs/guides/configuring-diesel-cli [print_schema] -file = "src/schema.rs" +file = "tests/schema.rs" custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] [migrations_directory] diff --git a/crates/tests/tests/diesel_crud_derive.rs b/crates/tests/tests/diesel_crud_derive.rs index f9b9417..bb96886 100644 --- a/crates/tests/tests/diesel_crud_derive.rs +++ b/crates/tests/tests/diesel_crud_derive.rs @@ -5,15 +5,9 @@ use lib::diesel_crud_derive::{ use lib::diesel_crud_trait::DieselCrudCreate; use test_containers::create_test_containers_pool; +mod schema; #[cfg(test)] -pub mod test_containers; - -diesel::table! { - user (email) { - #[max_length = 255] - email -> Varchar, - } -} +mod test_containers; #[derive( Debug, @@ -29,14 +23,14 @@ diesel::table! { DieselCrudUpdate, )] #[diesel_crud(insert = InsertUser)] -#[diesel(table_name = user)] +#[diesel(table_name = schema::user)] struct User { #[diesel_crud(pk)] email: String, } #[derive(Clone, Insertable)] -#[diesel(table_name = user)] +#[diesel(table_name = schema::user)] struct InsertUser { email: String, } diff --git a/crates/tests/tests/schema.rs b/crates/tests/tests/schema.rs new file mode 100644 index 0000000..e13ea97 --- /dev/null +++ b/crates/tests/tests/schema.rs @@ -0,0 +1,6 @@ +diesel::table! { + user (email) { + #[max_length = 255] + email -> Varchar, + } +} diff --git a/justfile b/justfile index ffc697a..a577ba1 100755 --- a/justfile +++ b/justfile @@ -4,10 +4,10 @@ run: cargo run fmt: - cargo fmt + cargo fmt --all lint: - cargo clippy + cargo clippy --all-targets --all-features -- -D warnings release: cargo build --release diff --git a/src/diesel/migration.rs b/src/diesel/migration.rs index 7318015..c26aa04 100644 --- a/src/diesel/migration.rs +++ b/src/diesel/migration.rs @@ -13,8 +13,7 @@ pub async fn run_migrations( where A: AsyncConnection + 'static, { - let mut async_wrapper: AsyncConnectionWrapper = - AsyncConnectionWrapper::from(async_connection); + let mut async_wrapper = AsyncConnectionWrapper::::from(async_connection); tokio::task::spawn_blocking(move || { async_wrapper.run_pending_migrations(migrations).unwrap();