Add automated test for testing the link target code.
Some checks failed
clippy Build clippy has failed
rust-test Build rust-test has succeeded
format Build format has succeeded

This commit is contained in:
Tom Alexander 2025-02-01 17:20:27 -05:00
parent aeca958cef
commit 7c92b602bc
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -42,7 +42,7 @@ intermediate!(
} }
); );
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq)]
pub(crate) enum LinkTarget { pub(crate) enum LinkTarget {
Raw(String), Raw(String),
Post { Post {
@ -124,3 +124,27 @@ impl LinkTarget {
} }
} }
} }
#[cfg(test)]
mod tests {
use std::sync::Arc;
use std::sync::Mutex;
use crate::intermediate::Registry;
use super::*;
#[test]
fn link_target_raw() -> Result<(), CustomError> {
let registry = Registry::new();
let registry = Arc::new(Mutex::new(registry));
let intermediate_context = IntermediateContext::new(registry)?;
for inp in ["https://test.example/foo"] {
assert_eq!(
LinkTarget::from_string(intermediate_context.clone(), inp.to_owned())?,
LinkTarget::Raw(inp.to_owned())
);
}
Ok(())
}
}