use std::path::Path;
use super::report::{ProofError, ProofReport};
pub trait ProofBackend {
fn render(&self, report: &ProofReport, output: &Path) -> Result<(), ProofError>;
}
#[cfg(test)]
mod tests {
use super::*;
struct StubBackend {
should_fail: bool,
}
impl ProofBackend for StubBackend {
fn render(&self, _report: &ProofReport, _output: &Path) -> Result<(), ProofError> {
if self.should_fail {
return Err(ProofError::Format("stub failure".to_string()));
}
Ok(())
}
}
#[test]
fn stub_backend_succeeds() {
let backend = StubBackend { should_fail: false };
let report = ProofReport::new("test");
let result = backend.render(&report, Path::new("/tmp/test.txt"));
assert!(result.is_ok());
}
#[test]
fn stub_backend_returns_error() {
let backend = StubBackend { should_fail: true };
let report = ProofReport::new("test");
let result = backend.render(&report, Path::new("/tmp/test.txt"));
assert!(result.is_err());
}
}