feat: add serial_test dependency and update tests for serial execution
This commit is contained in:
parent
fb16227325
commit
c3f7ba42b5
3 changed files with 49 additions and 0 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
@ -627,6 +627,7 @@ dependencies = [
|
|||
"migration",
|
||||
"sea-orm",
|
||||
"serde",
|
||||
"serial_test",
|
||||
"temp-env",
|
||||
"thiserror 2.0.12",
|
||||
"tracing-actix-web",
|
||||
|
@ -2803,12 +2804,27 @@ version = "1.0.20"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
|
||||
|
||||
[[package]]
|
||||
name = "scc"
|
||||
version = "2.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22b2d775fb28f245817589471dd49c5edf64237f4a19d10ce9a92ff4651a27f4"
|
||||
dependencies = [
|
||||
"sdd",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||
|
||||
[[package]]
|
||||
name = "sdd"
|
||||
version = "3.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "584e070911c7017da6cb2eb0788d09f43d789029b5877d3e5ecc8acf86ceee21"
|
||||
|
||||
[[package]]
|
||||
name = "sea-bae"
|
||||
version = "0.2.1"
|
||||
|
@ -3024,6 +3040,31 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"log",
|
||||
"once_cell",
|
||||
"parking_lot",
|
||||
"scc",
|
||||
"serial_test_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serial_test_derive"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.100",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.10.6"
|
||||
|
|
|
@ -31,6 +31,7 @@ dotenvy = "0.15"
|
|||
|
||||
[dev-dependencies]
|
||||
temp-env = "*"
|
||||
serial_test = "*"
|
||||
|
||||
[features]
|
||||
serve = []
|
||||
|
|
|
@ -120,10 +120,12 @@ fn build_database_url() -> String {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::env;
|
||||
use serial_test::serial;
|
||||
use super::*;
|
||||
use temp_env::{with_var, with_vars};
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn build_database_url_with_defaults() {
|
||||
with_vars(
|
||||
[
|
||||
|
@ -141,6 +143,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn build_database_url_with_all_vars() {
|
||||
with_vars(
|
||||
[
|
||||
|
@ -162,6 +165,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
#[should_panic(expected = "DB_HOST must be set in .env")]
|
||||
fn build_database_url_missing_host_panics() {
|
||||
with_var("DB_HOST", None::<&str>, || {
|
||||
|
@ -170,6 +174,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn connect_to_redis_database_with_defaults() {
|
||||
with_vars(
|
||||
[
|
||||
|
@ -193,6 +198,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn connect_to_redis_database_with_custom_port() {
|
||||
with_vars(
|
||||
[
|
||||
|
@ -217,6 +223,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[serial]
|
||||
fn check_if_no_env_variables_are_loaded_from_environment_file() {
|
||||
assert_eq!(env::var("DB_NAME"), Err(env::VarError::NotPresent));
|
||||
assert_eq!(env::var("DB_USER"), Err(env::VarError::NotPresent));
|
||||
|
|
Loading…
Add table
Reference in a new issue