From 97bed17fd2f6f86932ce2cc0da7a4e4a80e3e298 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Fri, 1 Dec 2017 16:10:01 -0800 Subject: [PATCH] test for completed pipeline state --- src/pipeline.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/pipeline.rs b/src/pipeline.rs index 1bb4fb4cf..5b4eb0efb 100644 --- a/src/pipeline.rs +++ b/src/pipeline.rs @@ -881,3 +881,36 @@ impl Completed { } } } + +#[cfg(test)] +mod tests { + use super::*; + use actix::*; + use context::HttpContext; + + impl PipelineState { + fn is_none(&self) -> Option { + if let PipelineState::None = *self { Some(true) } else { None } + } + fn is_completed(&self) -> Option { + if let PipelineState::Completed(_) = *self { Some(true) } else { None } + } + } + + struct MyActor; + impl Actor for MyActor { + type Context = HttpContext; + } + + #[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(); + } +}