From a80df869a92c330fbad9695057720b11a18af901 Mon Sep 17 00:00:00 2001 From: Doan Luu Duc Tai Date: Sat, 31 Oct 2026 13:08:08 -0500 Subject: Forbid Rust lints and enforce strict typed TypeScript linting --- crates/config/src/lib.rs | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'crates/config') 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(()) } } -- cgit v1.2.3