1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-24 07:53:00 +01:00

test for completed pipeline state

This commit is contained in:
Nikolay Kim 2017-12-01 16:10:01 -08:00
parent 47645626c4
commit 97bed17fd2

View File

@ -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();
}
}