diff options
| author | Doan Luu Duc Tai <doan@luuduct.ai> | 2026-10-31 13:08:08 -0500 |
|---|---|---|
| committer | Doan Luu Duc Tai <doan@luuduct.ai> | 2026-10-31 13:08:08 -0500 |
| commit | a80df869a92c330fbad9695057720b11a18af901 (patch) | |
| tree | 5307272821cb3adc3f0348413a3b904290890044 /crates/config/src | |
| parent | 9139398d465f5899cc31bc4cdd54daa7392ca550 (diff) | |
Forbid Rust lints and enforce strict typed TypeScript linting
Diffstat (limited to 'crates/config/src')
| -rw-r--r-- | crates/config/src/lib.rs | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index ce509b6..f5896d8 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -338,36 +338,47 @@ mod tests { let error = Config::load(root.path()) .err() .context("Malformed secret must fail")?; - assert!(!format!("{error:#}").contains("private-malformed-sentinel")); + anyhow::ensure!( + !format!("{error:#}").contains("private-malformed-sentinel"), + "Test invariant failed" + ); fs::write( root.path().join(".env"), "SITE_HOST=home.example.net\nGIT_HOST=source.example.net\nHTTPS_PORT=8443\nLOCAL_HTTP_PORT=8180\nCHAT_SETUP_TOKEN=private-token-sentinel\nSEARXNG_SECRET=private-search-sentinel\n", )?; let config = Config::load(root.path())?; - assert_eq!( - config.render("{{SITE_ORIGIN}} {{GIT_ORIGIN}}", None)?, - "https://home.example.net:8443 https://source.example.net:8443" + anyhow::ensure!( + (config.render("{{SITE_ORIGIN}} {{GIT_ORIGIN}}", None)?) + == ("https://home.example.net:8443 https://source.example.net:8443"), + "Test invariant failed" + ); + anyhow::ensure!( + (config.render("{{SITE_ORIGIN}} {{GIT_ORIGIN}}", Some(8180))?) + == ("http://localhost:8180 /git"), + "Test invariant failed" + ); + anyhow::ensure!( + config.render("{{CHAT_SETUP_TOKEN}}", None).is_err(), + "Test invariant failed" ); - assert_eq!( - config.render("{{SITE_ORIGIN}} {{GIT_ORIGIN}}", Some(8180))?, - "http://localhost:8180 /git" + anyhow::ensure!( + !format!("{config:?}").contains("private-token"), + "Test invariant failed" ); - assert!(config.render("{{CHAT_SETUP_TOKEN}}", None).is_err()); - assert!(!format!("{config:?}").contains("private-token")); initialize_public(root.path())?; - assert_eq!( - Config::load(root.path())?.value("SITE_HOST")?, - "home.example.net" + anyhow::ensure!( + (Config::load(root.path())?.value("SITE_HOST")?) == ("home.example.net"), + "Test invariant failed" ); - assert_eq!( - Config::load(root.path())?.value("CHAT_SETUP_TOKEN")?, - "private-token-sentinel" + anyhow::ensure!( + (Config::load(root.path())?.value("CHAT_SETUP_TOKEN")?) == ("private-token-sentinel"), + "Test invariant failed" ); fs::write( root.path().join(".env"), "SITE_HOST=\"valid.example { respond bad }\"\n", )?; - assert!(Config::load(root.path()).is_err()); + anyhow::ensure!(Config::load(root.path()).is_err(), "Test invariant failed"); Ok(()) } } |
