use crate::context::GarrisonResponse;
use crate::error::GarrisonResult;
use std::collections::HashMap;
pub struct MockResponse {
pub cookies: HashMap<String, String>,
pub headers: HashMap<String, String>,
pub status: Option<u16>,
}
impl MockResponse {
pub fn new() -> Self {
Self {
cookies: HashMap::new(),
headers: HashMap::new(),
status: None,
}
}
}
impl GarrisonResponse for MockResponse {
fn set_status(&mut self, code: u16) -> GarrisonResult<()> {
self.status = Some(code);
Ok(())
}
fn set_header(&mut self, name: &str, value: &str) -> GarrisonResult<()> {
self.headers.insert(name.to_string(), value.to_string());
Ok(())
}
fn set_cookie_with_config(
&mut self,
name: &str,
value: &str,
_config: &crate::config::GarrisonConfig,
) -> GarrisonResult<()> {
self.cookies.insert(name.to_string(), value.to_string());
Ok(())
}
}