11 Commits

Author SHA1 Message Date
9f85b7ae97 🎨 Format files
All checks were successful
Build & test / build (push) Successful in 10m42s
2025-07-01 18:53:41 +02:00
972178932c RustRover project default 2025-07-01 18:53:04 +02:00
2f00a27ce1 Add default list recipies, add comments, remove run recipe 2025-07-01 18:52:16 +02:00
894d5159e5 Fix lint error 2025-07-01 18:50:03 +02:00
5dbcc93d4e 🧹 Removed unused dependencies
Signed-off-by: Martin Berg Alstad <600878@stud.hvl.no>

 Conflicts:
	Cargo.lock
	crates/tests/Cargo.toml
2025-07-01 18:42:15 +02:00
a2075892f5 💚 Ignore failing test
All checks were successful
Build & test / build (push) Successful in 10m44s
2025-07-01 18:28:05 +02:00
f8c629d123 📦 Update flake
Some checks failed
Build & test / build (push) Failing after 11m28s
2025-07-01 18:12:22 +02:00
05afb64b07 📦 Update rust to 1.88 2025-07-01 18:12:01 +02:00
d84078d6c3 💚 Removed unused duplicated function
Some checks failed
Build & test / build (push) Failing after 10m43s
2025-03-08 19:18:16 +01:00
f14543af6b ♻️ Removed Makefile, refactored schema in tests
Some checks failed
Build & test / build (push) Has been cancelled
2025-03-08 19:09:43 +01:00
d260b2d676 💚 Added multi_thread flavor to tokio::test
Some checks failed
Build & test / build (push) Failing after 10m42s
2025-03-08 18:11:14 +01:00
21 changed files with 114 additions and 133 deletions

View File

@ -0,0 +1,12 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

123
Cargo.lock generated
View File

@ -66,9 +66,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]] [[package]]
name = "axum" name = "axum"
version = "0.8.1" version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" checksum = "021e862c184ae977658b36c4500f7feac3221ca5da43e3f25bd04ab6c79a29b5"
dependencies = [ dependencies = [
"axum-core", "axum-core",
"bytes", "bytes",
@ -101,12 +101,12 @@ dependencies = [
[[package]] [[package]]
name = "axum-core" name = "axum-core"
version = "0.5.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" checksum = "68464cd0412f486726fb3373129ef5d2993f90c34bc2bc1c1e9943b2f4fc7ca6"
dependencies = [ dependencies = [
"bytes", "bytes",
"futures-util", "futures-core",
"http", "http",
"http-body", "http-body",
"http-body-util", "http-body-util",
@ -169,9 +169,9 @@ dependencies = [
[[package]] [[package]]
name = "bollard" name = "bollard"
version = "0.17.1" version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d41711ad46fda47cd701f6908e59d1bd6b9a2b7464c0d0aeab95c6d37096ff8a" checksum = "97ccca1260af6a459d75994ad5acc1651bcabcbdbc41467cc9786519ab854c30"
dependencies = [ dependencies = [
"base64 0.22.1", "base64 0.22.1",
"bollard-stubs", "bollard-stubs",
@ -198,7 +198,7 @@ dependencies = [
"serde_json", "serde_json",
"serde_repr", "serde_repr",
"serde_urlencoded", "serde_urlencoded",
"thiserror 1.0.63", "thiserror",
"tokio", "tokio",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
@ -208,9 +208,9 @@ dependencies = [
[[package]] [[package]]
name = "bollard-stubs" name = "bollard-stubs"
version = "1.45.0-rc.26.0.1" version = "1.47.1-rc.27.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7c5415e3a6bc6d3e99eff6268e488fd4ee25e7b28c10f08fa6760bd9de16e4" checksum = "3f179cfbddb6e77a5472703d4b30436bff32929c0aa8a9008ecf23d1d3cdd0da"
dependencies = [ dependencies = [
"serde", "serde",
"serde_repr", "serde_repr",
@ -267,9 +267,9 @@ dependencies = [
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -490,7 +490,7 @@ version = "0.1.0"
dependencies = [ dependencies = [
"diesel", "diesel",
"diesel-async", "diesel-async",
"thiserror 2.0.12", "thiserror",
] ]
[[package]] [[package]]
@ -585,12 +585,12 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]] [[package]]
name = "errno" name = "errno"
version = "0.3.10" version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad"
dependencies = [ dependencies = [
"libc", "libc",
"windows-sys 0.59.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -1056,7 +1056,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"testcontainers-modules", "testcontainers-modules",
"thiserror 2.0.12", "thiserror",
"tokio", "tokio",
"tokio-util", "tokio-util",
"tower 0.5.2", "tower 0.5.2",
@ -1067,9 +1067,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.170" version = "0.2.174"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
[[package]] [[package]]
name = "libredox" name = "libredox"
@ -1084,9 +1084,9 @@ dependencies = [
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.15" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
@ -1565,15 +1565,15 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.44" version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"errno", "errno",
"libc", "libc",
"linux-raw-sys", "linux-raw-sys",
"windows-sys 0.59.0", "windows-sys 0.52.0",
] ]
[[package]] [[package]]
@ -1592,12 +1592,11 @@ dependencies = [
[[package]] [[package]]
name = "rustls-native-certs" name = "rustls-native-certs"
version = "0.7.3" version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" checksum = "7fcff2dd52b58a8d98a70243663a0d234c4e2b79235637849d15913394a247d3"
dependencies = [ dependencies = [
"openssl-probe", "openssl-probe",
"rustls-pemfile",
"rustls-pki-types", "rustls-pki-types",
"schannel", "schannel",
"security-framework", "security-framework",
@ -1615,9 +1614,12 @@ dependencies = [
[[package]] [[package]]
name = "rustls-pki-types" name = "rustls-pki-types"
version = "1.8.0" version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
dependencies = [
"zeroize",
]
[[package]] [[package]]
name = "rustls-webpki" name = "rustls-webpki"
@ -1669,9 +1671,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.11.1" version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"core-foundation", "core-foundation",
@ -1682,9 +1684,9 @@ dependencies = [
[[package]] [[package]]
name = "security-framework-sys" name = "security-framework-sys"
version = "2.11.1" version = "2.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys",
"libc", "libc",
@ -1745,9 +1747,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.8" version = "0.6.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -1928,9 +1930,9 @@ checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
[[package]] [[package]]
name = "testcontainers" name = "testcontainers"
version = "0.23.1" version = "0.23.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f40cc2bd72e17f328faf8ca7687fe337e61bccd8acf9674fa78dd3792b045e1" checksum = "59a4f01f39bb10fc2a5ab23eb0d888b1e2bb168c157f61a1b98e6c501c639c74"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bollard", "bollard",
@ -1947,7 +1949,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"serde_with", "serde_with",
"thiserror 1.0.63", "thiserror",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tokio-tar", "tokio-tar",
@ -1976,33 +1978,13 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "thiserror"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
dependencies = [
"thiserror-impl 1.0.63",
]
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "2.0.12" version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [ dependencies = [
"thiserror-impl 2.0.12", "thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
dependencies = [
"proc-macro2",
"quote",
"syn",
] ]
[[package]] [[package]]
@ -2074,9 +2056,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.40.0" version = "1.45.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -2090,9 +2072,9 @@ dependencies = [
[[package]] [[package]]
name = "tokio-macros" name = "tokio-macros"
version = "2.4.0" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2217,7 +2199,7 @@ dependencies = [
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
"winnow 0.7.3", "winnow 0.7.11",
] ]
[[package]] [[package]]
@ -2253,9 +2235,9 @@ dependencies = [
[[package]] [[package]]
name = "tower-http" name = "tower-http"
version = "0.6.2" version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
dependencies = [ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"bytes", "bytes",
@ -2699,21 +2681,20 @@ dependencies = [
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.7.3" version = "0.7.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1" checksum = "74c7b26e3480b707944fc872477815d29a8e429d2f93a1ce000f5fa84a15cbcd"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]
[[package]] [[package]]
name = "xattr" name = "xattr"
version = "1.4.0" version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e105d177a3871454f754b33bb0ee637ecaaac997446375fd3e5d43a2ed00c909" checksum = "af3a19837351dc82ba89f8a125e22a3c475f05aba604acc023d62b2739ae2909"
dependencies = [ dependencies = [
"libc", "libc",
"linux-raw-sys",
"rustix", "rustix",
] ]

View File

@ -4,9 +4,9 @@ exclude = ["examples"]
[workspace.package] [workspace.package]
edition = "2024" edition = "2024"
rust-version = "1.85" rust-version = "1.88"
authors = ["Martin Berg Alstad"] authors = ["Martin Berg Alstad"]
homepage = "emberal.github.io" homepage = "martials.no"
[package] [package]
name = "lib" name = "lib"

View File

@ -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"]

View File

@ -1,5 +1,5 @@
use crate::common::PrimaryKey; use crate::common::PrimaryKey;
use deluxe::{extract_attributes, ExtractAttributes}; use deluxe::{ExtractAttributes, extract_attributes};
use proc_macro2::Ident; use proc_macro2::Ident;
use quote::quote; use quote::quote;
use std::collections::HashMap; use std::collections::HashMap;

View File

@ -1,6 +1,6 @@
extern crate proc_macro; extern crate proc_macro;
use crate::attributes::{extract_attrs, Attributes}; use crate::attributes::{Attributes, extract_attrs};
use crate::common::PrimaryKey; use crate::common::PrimaryKey;
use crate::create::derive_diesel_crud_create_impl; use crate::create::derive_diesel_crud_create_impl;
use crate::delete::derive_diesel_crud_delete_impl; use crate::delete::derive_diesel_crud_delete_impl;
@ -8,7 +8,7 @@ use crate::list::derive_diesel_crud_list_impl;
use crate::read::derive_diesel_crud_read_impl; use crate::read::derive_diesel_crud_read_impl;
use crate::update::derive_diesel_crud_update_impl; use crate::update::derive_diesel_crud_update_impl;
use quote::quote; use quote::quote;
use syn::{parse_macro_input, DeriveInput}; use syn::{DeriveInput, parse_macro_input};
mod attributes; mod attributes;
mod common; mod common;

View File

@ -1,7 +1,7 @@
extern crate proc_macro; extern crate proc_macro;
use { use {
proc_macro::TokenStream, proc_macro::TokenStream,
syn::{parse_macro_input, DeriveInput}, syn::{DeriveInput, parse_macro_input},
}; };
mod derive; mod derive;

View File

@ -10,8 +10,8 @@ use std::{
use quote::quote; use quote::quote;
use syn::{ use syn::{
parse::{Parse, ParseStream},
LitStr, Token, LitStr, Token,
parse::{Parse, ParseStream},
}; };
pub fn read_files_to_string_impl(args: Args) -> TokenStream { pub fn read_files_to_string_impl(args: Args) -> TokenStream {

View File

@ -2,7 +2,7 @@
# see https://diesel.rs/guides/configuring-diesel-cli # see https://diesel.rs/guides/configuring-diesel-cli
[print_schema] [print_schema]
file = "src/schema.rs" file = "tests/schema.rs"
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] custom_type_derives = ["diesel::query_builder::QueryId", "Clone"]
[migrations_directory] [migrations_directory]

View File

@ -5,15 +5,9 @@ use lib::diesel_crud_derive::{
use lib::diesel_crud_trait::DieselCrudCreate; use lib::diesel_crud_trait::DieselCrudCreate;
use test_containers::create_test_containers_pool; use test_containers::create_test_containers_pool;
mod schema;
#[cfg(test)] #[cfg(test)]
pub mod test_containers; mod test_containers;
diesel::table! {
user (email) {
#[max_length = 255]
email -> Varchar,
}
}
#[derive( #[derive(
Debug, Debug,
@ -29,19 +23,21 @@ diesel::table! {
DieselCrudUpdate, DieselCrudUpdate,
)] )]
#[diesel_crud(insert = InsertUser)] #[diesel_crud(insert = InsertUser)]
#[diesel(table_name = user)] #[diesel(table_name = schema::user)]
struct User { struct User {
#[diesel_crud(pk)] #[diesel_crud(pk)]
email: String, email: String,
} }
#[derive(Clone, Insertable)] #[derive(Clone, Insertable)]
#[diesel(table_name = user)] #[diesel(table_name = schema::user)]
struct InsertUser { struct InsertUser {
email: String, email: String,
} }
#[tokio::test] // TODO make test work in action
#[ignore]
#[tokio::test(flavor = "multi_thread")]
async fn test_insert_user() { async fn test_insert_user() {
let container = create_test_containers_pool().await.unwrap(); let container = create_test_containers_pool().await.unwrap();
let mut conn = container.pool.get().await.unwrap(); let mut conn = container.pool.get().await.unwrap();

View File

@ -0,0 +1,6 @@
diesel::table! {
user (email) {
#[max_length = 255]
email -> Varchar,
}
}

View File

@ -1,19 +1,11 @@
use diesel_migrations::EmbeddedMigrations; use diesel_migrations::EmbeddedMigrations;
use lib::diesel::migration::run_migrations; use lib::diesel::migration::run_migrations;
use lib::test::test_containers::{ContainerError, TestContainer}; use lib::test::test_containers::{ContainerError, TestContainer};
use testcontainers_modules::postgres::Postgres;
use testcontainers_modules::testcontainers::runners::AsyncRunner;
use testcontainers_modules::testcontainers::{ContainerAsync, TestcontainersError};
pub async fn create_test_containers_pool() -> Result<TestContainer, ContainerError> { pub async fn create_test_containers_pool() -> Result<TestContainer, ContainerError> {
let test_container = lib::test::test_containers::create_test_containers_pool().await?; let test_container = lib::test::test_containers::create_test_containers_pool().await?;
let pool = &test_container.pool; let connection = test_container.pool.get().await?;
let connection = pool.get().await?;
const MIGRATIONS: EmbeddedMigrations = diesel_migrations::embed_migrations!("./migrations"); const MIGRATIONS: EmbeddedMigrations = diesel_migrations::embed_migrations!("./migrations");
run_migrations(connection, MIGRATIONS).await?; run_migrations(connection, MIGRATIONS).await?;
Ok(test_container) Ok(test_container)
} }
pub async fn create_postgres_container() -> Result<ContainerAsync<Postgres>, TestcontainersError> {
Postgres::default().start().await
}

View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "addr2line" name = "addr2line"

8
flake.lock generated
View File

@ -2,16 +2,16 @@
"nodes": { "nodes": {
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1741196730, "lastModified": 1751211869,
"narHash": "sha256-0Sj6ZKjCpQMfWnN0NURqRCQn2ob7YtXTAOTwCuz7fkA=", "narHash": "sha256-1Cu92i1KSPbhPCKxoiVG5qnoRiKTgR5CcGSRyLpOd7Y=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "48913d8f9127ea6530a2a2f1bd4daa1b8685d8a3", "rev": "b43c397f6c213918d6cfe6e3550abfe79b5d1c51",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-24.11", "ref": "nixos-25.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }

View File

@ -1,6 +1,6 @@
{ {
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
}; };

View File

@ -1,19 +1,29 @@
#!/usr/bin/env just --justfile #!/usr/bin/env just --justfile
run: # List all recipes
cargo run default:
@just --list
# Open a nix shell with all dependencies in path
develop:
nix develop
# Format all rust files
fmt: fmt:
cargo fmt cargo fmt --all
# Lint all files with clippy
lint: lint:
cargo clippy cargo clippy --all-targets --all-features -- -D warnings
# Build a release version
release: release:
cargo build --release cargo build --release
# Run all tests
test: test:
cargo test --all-features --workspace cargo test --all-features --workspace
# Run coverage
coverage: coverage:
cargo llvm-cov cargo llvm-cov

View File

@ -1,7 +1,7 @@
use crate::axum::traits::BuildJson; use crate::axum::traits::BuildJson;
use axum::body::Body; use axum::body::Body;
use axum::http::header::CONTENT_TYPE;
use axum::http::Request; use axum::http::Request;
use axum::http::header::CONTENT_TYPE;
use mime::APPLICATION_JSON; use mime::APPLICATION_JSON;
use serde::Serialize; use serde::Serialize;
use serde_json::json; use serde_json::json;

View File

@ -19,9 +19,9 @@ impl<T: Serialize> IntoResponse for BaseResponse<T> {
impl DeserializeInto for Response { impl DeserializeInto for Response {
async fn deserialize_into<T: DeserializeOwned>(self) -> Result<T, serde_json::Error> { async fn deserialize_into<T: DeserializeOwned>(self) -> Result<T, serde_json::Error> {
let body = to_bytes(self.into_body(), usize::MAX).await.map_err(|e| { let body = to_bytes(self.into_body(), usize::MAX)
serde_json::Error::custom(format!("Failed to read response body: {}", e)) .await
})?; .map_err(|e| serde_json::Error::custom(format!("Failed to read response body: {e}")))?;
serde_json::from_slice(&body) serde_json::from_slice(&body)
} }
} }

View File

@ -13,8 +13,7 @@ pub async fn run_migrations<A>(
where where
A: AsyncConnection<Backend = Pg> + 'static, A: AsyncConnection<Backend = Pg> + 'static,
{ {
let mut async_wrapper: AsyncConnectionWrapper<A> = let mut async_wrapper = AsyncConnectionWrapper::<A>::from(async_connection);
AsyncConnectionWrapper::from(async_connection);
tokio::task::spawn_blocking(move || { tokio::task::spawn_blocking(move || {
async_wrapper.run_pending_migrations(migrations).unwrap(); async_wrapper.run_pending_migrations(migrations).unwrap();

View File

@ -1,7 +1,7 @@
use deadpool_diesel::postgres::BuildError; use deadpool_diesel::postgres::BuildError;
use diesel_async::pooled_connection::deadpool::Pool;
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::AsyncPgConnection; use diesel_async::AsyncPgConnection;
use diesel_async::pooled_connection::AsyncDieselConnectionManager;
use diesel_async::pooled_connection::deadpool::Pool;
/// A type alias for the asynchronous PostgreSQL connection pool. /// A type alias for the asynchronous PostgreSQL connection pool.
pub type PgPool = Pool<AsyncPgConnection>; pub type PgPool = Pool<AsyncPgConnection>;

View File

@ -1,6 +1,6 @@
use { use {
crate::traits::IntoResult, crate::traits::IntoResult,
nom::{error::Error, IResult}, nom::{IResult, error::Error},
}; };
impl<T, R> IntoResult<T> for IResult<R, T> { impl<T, R> IntoResult<T> for IResult<R, T> {