1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-19 22:56:39 +00:00

payload error tests

This commit is contained in:
Nikolay Kim 2017-10-23 14:08:11 -07:00
parent 1cdfea39f0
commit 4d93766a0f
2 changed files with 14 additions and 1 deletions

View file

@ -365,9 +365,22 @@ impl Inner {
#[cfg(test)]
mod tests {
use super::*;
use std::io;
use futures::future::{lazy, result};
use tokio_core::reactor::Core;
#[test]
fn test_error() {
let err: PayloadError = IoError::new(io::ErrorKind::Other, "ParseError").into();
assert_eq!(err.description(), "ParseError");
assert_eq!(err.cause().unwrap().description(), "ParseError");
assert_eq!(format!("{}", err), "ParseError");
let err = PayloadError::Incomplete;
assert_eq!(err.description(), "A payload reached EOF, but is not complete.");
assert_eq!(format!("{}", err), "A payload reached EOF, but is not complete.");
}
#[test]
fn test_basic() {
Core::new().unwrap().run(lazy(|| {

View file

@ -340,7 +340,7 @@ mod tests {
assert!(Frame::parse(&mut buf).unwrap().is_none());
buf.extend(b"1");
let frame = Frame::parse(&mut buf).unwrap().unwrap();
println!("FRAME: {:?}", frame);
println!("FRAME: {}", frame);
assert!(!frame.finished);
assert_eq!(frame.opcode, OpCode::Text);
assert_eq!(frame.payload, &b"1"[..]);