mirror of
https://github.com/actix/actix-web.git
synced 2025-01-03 13:58:44 +00:00
test for completed pipeline state
This commit is contained in:
parent
47645626c4
commit
97bed17fd2
1 changed files with 33 additions and 0 deletions
|
@ -881,3 +881,36 @@ impl Completed {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use actix::*;
|
||||||
|
use context::HttpContext;
|
||||||
|
|
||||||
|
impl PipelineState {
|
||||||
|
fn is_none(&self) -> Option<bool> {
|
||||||
|
if let PipelineState::None = *self { Some(true) } else { None }
|
||||||
|
}
|
||||||
|
fn is_completed(&self) -> Option<bool> {
|
||||||
|
if let PipelineState::Completed(_) = *self { Some(true) } else { None }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MyActor;
|
||||||
|
impl Actor for MyActor {
|
||||||
|
type Context = HttpContext<MyActor>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_completed() {
|
||||||
|
let info = Box::new(PipelineInfo::new(HttpRequest::default()));
|
||||||
|
Completed::init(info).is_none().unwrap();
|
||||||
|
|
||||||
|
let req = HttpRequest::default();
|
||||||
|
let ctx = HttpContext::new(req.clone(), MyActor);
|
||||||
|
let mut info = Box::new(PipelineInfo::new(req));
|
||||||
|
info.context = Some(Box::new(ctx));
|
||||||
|
Completed::init(info).is_completed().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue