Skip to content

Commit

Permalink
test: add test for error reason
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Dec 31, 2023
1 parent 4664a34 commit 7071c9d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,20 @@ pub enum ScriptError {
#[error(transparent)]
ParseError(#[from] ParseError),
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_source_error() {
let reason = RenderErrorReason::TemplateNotFound("unnamed".to_owned());
let render_error = RenderError::from(reason);

let reason2 = render_error.source().unwrap();
assert!(matches!(
reason2.downcast_ref::<RenderErrorReason>().unwrap(),
RenderErrorReason::TemplateNotFound(_)
));
}
}

0 comments on commit 7071c9d

Please sign in to comment.