use gradatum_core::error::GradatumError;
#[test]
fn inference_variant_displays_message() {
let err = GradatumError::Inference("backend HTTP timeout".to_string());
let msg = format!("{err}");
assert!(
msg.contains("inference"),
"Display doit contenir 'inference', got: {msg}"
);
assert!(
msg.contains("backend HTTP timeout"),
"Display doit contenir le message source, got: {msg}"
);
}
#[test]
fn inference_variant_propagates_via_question_mark() {
fn produce() -> Result<(), GradatumError> {
Err(GradatumError::Inference("embed dim mismatch".to_string()))
}
fn consume() -> Result<(), GradatumError> {
produce()?;
Ok(())
}
let res = consume();
assert!(matches!(res, Err(GradatumError::Inference(_))));
}
#[test]
fn inference_variant_distinct_from_storage() {
let inf = GradatumError::Inference("dim mismatch".into());
let store = GradatumError::Storage("disk full".into());
assert!(matches!(inf, GradatumError::Inference(_)));
assert!(matches!(store, GradatumError::Storage(_)));
assert!(!matches!(inf, GradatumError::Storage(_)));
assert!(!matches!(store, GradatumError::Inference(_)));
}