28 lines
842 B
Rust
28 lines
842 B
Rust
//! Vérifie le mapping depuis anyhow::Error vers AnkError
|
|
|
|
use sdk_common::error::AnkError;
|
|
|
|
#[test]
|
|
fn anyhow_to_ankerror_generic() {
|
|
let any = anyhow::anyhow!("some generic failure");
|
|
let mapped: AnkError = any.into();
|
|
match mapped {
|
|
AnkError::GenericError(msg) => assert!(msg.contains("generic")),
|
|
_ => panic!("mapping inattendu"),
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn anyhow_to_ankerror_specific_variants() {
|
|
for (needle, expect_variant) in [
|
|
("FaucetError: oops", "FaucetError"),
|
|
("NewTxError: oops", "NewTxError"),
|
|
("CipherError: oops", "CipherError"),
|
|
] {
|
|
let any = anyhow::anyhow!(needle);
|
|
let mapped: AnkError = any.into();
|
|
let label = format!("{:?}", mapped);
|
|
assert!(label.contains(expect_variant), "{} should map to {}", needle, expect_variant);
|
|
}
|
|
}
|