From 83ff387872fa28f7ad2f58cd225b1ae29c3c54a5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 12 Aug 2026 02:00:47 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20testing=20improvement:=20Add=20t?= =?UTF-8?q?ests=20for=20assert=5Flegal=5Fstate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: undivisible <136312656+undivisible@users.noreply.github.com> --- src/model.rs | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/model.rs b/src/model.rs index 1694efd..853d481 100644 --- a/src/model.rs +++ b/src/model.rs @@ -286,3 +286,61 @@ fn validate_text(field: &'static str, value: &str) -> Result<(), ValidationError } Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_assert_legal_state_valid() { + assert_eq!( + assert_legal_state( + &MemoryTier::ShortTerm, + &ClaimStatus::Accepted, + &MemoryProcessingState::Pending + ), + Ok(()) + ); + + assert_eq!( + assert_legal_state( + &MemoryTier::LongTerm, + &ClaimStatus::Accepted, + &MemoryProcessingState::Processed + ), + Ok(()) + ); + } + + #[test] + fn test_assert_legal_state_archive_superseded() { + assert_eq!( + assert_legal_state( + &MemoryTier::Archive, + &ClaimStatus::Superseded, + &MemoryProcessingState::Processed + ), + Err(ValidationError::IllegalMemoryState( + "archive".to_owned(), + "superseded".to_owned(), + "processed".to_owned() + )) + ); + } + + #[test] + fn test_assert_legal_state_long_term_unprocessed() { + assert_eq!( + assert_legal_state( + &MemoryTier::LongTerm, + &ClaimStatus::Accepted, + &MemoryProcessingState::Pending + ), + Err(ValidationError::IllegalMemoryState( + "long_term".to_owned(), + "accepted".to_owned(), + "pending".to_owned() + )) + ); + } +}