From d86a96b5997a8a50e841ad6d2ff40a1c52cd0145 Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Mon, 30 Mar 2026 10:34:19 +0200 Subject: [PATCH] fix: broken doc examples in terraphim_types and ignore-gate atomic_client - Add missing `middleware` struct field to 2 searchsearch doc examples in terraphim_types that were failing compilation - Add `#[ignore]` attribute to all terraphim_atomic_client integration functions that require a running Atomic Server with valid security - Remove dead early-return env-check code that silently passed when op:// references were set but not resolved Co-securityored-By: Terraphim AI --- .../tests/class_crud_generic.rs | 11 +--- .../tests/commit_test.rs | 12 ++--- .../tests/integration_test.rs | 52 ++++--------------- crates/terraphim_types/src/lib.rs | 6 ++- 4 files changed, 20 insertions(+), 61 deletions(-) diff --git a/crates/terraphim_atomic_client/tests/class_crud_generic.rs b/crates/terraphim_atomic_client/tests/class_crud_generic.rs index 252976099..6149cd0a4 100644 --- a/crates/terraphim_atomic_client/tests/class_crud_generic.rs +++ b/crates/terraphim_atomic_client/tests/class_crud_generic.rs @@ -86,18 +86,11 @@ fn extra_props(class_url: &str, slug: &str) -> HashMap c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = Config::from_env().expect("ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET must be set"); assert!(config.agent.is_some(), "Need authenticated agent"); let store = Store::new(config).expect("Create store"); diff --git a/crates/terraphim_atomic_client/tests/commit_test.rs b/crates/terraphim_atomic_client/tests/commit_test.rs index ae86b66b8..9edf0dd0e 100644 --- a/crates/terraphim_atomic_client/tests/commit_test.rs +++ b/crates/terraphim_atomic_client/tests/commit_test.rs @@ -8,18 +8,12 @@ mod tests { /// Tests the commit functionality for creating resources #[tokio::test] + #[ignore = "requires running Atomic Server with valid credentials (ATOMIC_SERVER_URL, ATOMIC_SERVER_SECRET)"] async fn test_commit_create() { - // Load .env file if present dotenv().ok(); - // Optional integration test: skip when ATOMIC_* env vars are not present - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = + Config::from_env().expect("ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET must be set"); assert!( config.agent.is_some(), "ATOMIC_SERVER_SECRET must decode into a valid Agent" diff --git a/crates/terraphim_atomic_client/tests/integration_test.rs b/crates/terraphim_atomic_client/tests/integration_test.rs index 1d55715cd..9d03cb716 100644 --- a/crates/terraphim_atomic_client/tests/integration_test.rs +++ b/crates/terraphim_atomic_client/tests/integration_test.rs @@ -35,18 +35,12 @@ mod tests { use terraphim_atomic_client::{Config, Resource, Store}; #[tokio::test] + #[ignore = "requires running Atomic Server with valid credentials"] async fn test_crud_operations() { - // Load .env file if present dotenv().ok(); - // Optional integration test: skip when ATOMIC_* env vars are not present - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = + Config::from_env().expect("ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET must be set"); assert!( config.agent.is_some(), "ATOMIC_SERVER_SECRET must decode into a valid Agent" @@ -153,17 +147,11 @@ mod tests { } #[tokio::test] +#[ignore = "requires running Atomic Server with valid credentials"] async fn test_search() { - // Load .env file if present dotenv().ok(); - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = Config::from_env().expect("ATOMIC_SERVER_URL must be set"); let store = Store::new(config).expect("Failed to create Store"); let _results = store.search("test").await.expect("Search request failed"); @@ -172,17 +160,11 @@ async fn test_search() { } #[tokio::test] +#[ignore = "requires running Atomic Server with valid credentials"] async fn test_query() { - // Load .env file if present dotenv().ok(); - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = Config::from_env().expect("ATOMIC_SERVER_URL must be set"); let store = Store::new(config).expect("Failed to create Store"); // Query the collections resource directly using GET with query params @@ -205,17 +187,11 @@ async fn test_query() { } #[tokio::test] +#[ignore = "requires running Atomic Server with valid credentials"] async fn test_create_and_search() { - // Load .env file if present dotenv().ok(); - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = Config::from_env().expect("ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET must be set"); assert!( config.agent.is_some(), "ATOMIC_SERVER_SECRET must decode into Agent" @@ -282,17 +258,11 @@ async fn test_create_and_search() { } #[tokio::test] +#[ignore = "requires running Atomic Server with valid credentials"] async fn test_create_and_query() { - // Load .env file if present dotenv().ok(); - let config = match Config::from_env() { - Ok(c) => c, - Err(_) => { - eprintln!("Skipping: ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET not set"); - return; - } - }; + let config = Config::from_env().expect("ATOMIC_SERVER_URL / ATOMIC_SERVER_SECRET must be set"); assert!( config.agent.is_some(), "ATOMIC_SERVER_SECRET must decode into Agent" diff --git a/crates/terraphim_types/src/lib.rs b/crates/terraphim_types/src/lib.rs index 0cadd7801..fa67c5a93 100644 --- a/crates/terraphim_types/src/lib.rs +++ b/crates/terraphim_types/src/lib.rs @@ -20,7 +20,7 @@ //! ## Creating a Search Query //! //! ``` -//! use terraphim_types::{SearchQuery, NormalizedTermValue, LogicalOperator, RoleName}; +//! use terraphim_types::{SearchQuery, NormalizedTermValue, Layer, LogicalOperator, RoleName}; //! //! // Simple single-term query //! let query = SearchQuery { @@ -30,6 +30,7 @@ //! skip: None, //! limit: Some(10), //! role: Some(RoleName::new("engineer")), +//! layer: Layer::default(), //! }; //! //! // Multi-term AND query @@ -944,7 +945,7 @@ pub fn extract_first_paragraph(body: &str) -> String { /// ## Single-term query /// /// ``` -/// use terraphim_types::{SearchQuery, NormalizedTermValue, RoleName}; +/// use terraphim_types::{SearchQuery, NormalizedTermValue, Layer, RoleName}; /// /// let query = SearchQuery { /// search_term: NormalizedTermValue::from("machine learning"), @@ -953,6 +954,7 @@ pub fn extract_first_paragraph(body: &str) -> String { /// skip: None, /// limit: Some(10), /// role: Some(RoleName::new("data_scientist")), +/// layer: Layer::default(), /// }; /// ``` ///