// file: crates/ksp-core-lib/tests/public_api.rs // version: 2 //! Integration tests for the public `ksp-core-lib` error contract. fn public_result() -> ksp_core_lib::Result<()> { let error = ksp_core_lib::Error::new(ksp_core_lib::ErrorCode::new("consumer", "failed"), "consumer failure").with_context("operation", "public_api"); return std::result::Result::Err(error); } #[test] fn error_contract_is_consumable_from_crate_root() { let result = public_result(); assert!(result.is_err()); let error = match result { std::result::Result::Ok(()) => return, std::result::Result::Err(error) => error, }; assert_eq!(error.code(), ksp_core_lib::ErrorCode::new("consumer", "failed")); assert_eq!(error.message(), "consumer failure"); assert_eq!(error.context(), &[ksp_core_lib::ErrorContext::new("operation", "public_api")]); assert_eq!(std::string::ToString::to_string(&error), "consumer.failed: consumer failure"); return; }