1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 10:42:55 +01:00

add exclude pattern for tests

This commit is contained in:
Nikolay Kim 2017-10-23 14:26:01 -07:00
parent 4d93766a0f
commit efada51f12
2 changed files with 57 additions and 2 deletions

View File

@ -61,8 +61,8 @@ after_success:
make install DESTDIR=../../kcov-build &&
cd ../.. &&
rm -rf kcov-master &&
for file in target/debug/actix_web-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
for file in target/debug/test_*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --verify "target/cov/$(basename $file)" "$file"; done &&
for file in target/debug/actix_web-*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib --exclude-region='#[cfg(test)]:' --verify "target/cov/$(basename $file)" "$file"; done &&
for file in target/debug/test_*[^\.d]; do mkdir -p "target/cov/$(basename $file)"; ./kcov-build/usr/local/bin/kcov --exclude-pattern=/.cargo,/usr/lib,test_ --verify "target/cov/$(basename $file)" "$file"; done &&
bash <(curl -s https://codecov.io/bash) &&
echo "Uploaded code coverage"
fi

View File

@ -288,3 +288,58 @@ impl Future for UrlEncoded {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use http::{Uri, HttpTryFrom};
// use futures::future::{lazy, result};
// use tokio_core::reactor::Core;
use payload::Payload;
#[test]
fn test_urlencoded_error() {
let mut headers = HeaderMap::new();
headers.insert(header::TRANSFER_ENCODING,
header::HeaderValue::from_static("chunked"));
let req = HttpRequest::new(
Method::GET, Uri::try_from("/").unwrap(), Version::HTTP_11, headers);
let (_, payload) = Payload::new(false);
assert!(req.urlencoded(payload).is_err());
let mut headers = HeaderMap::new();
headers.insert(header::CONTENT_TYPE,
header::HeaderValue::from_static("application/x-www-form-urlencoded"));
headers.insert(header::CONTENT_LENGTH,
header::HeaderValue::from_static("xxxx"));
let req = HttpRequest::new(
Method::GET, Uri::try_from("/").unwrap(), Version::HTTP_11, headers);
let (_, payload) = Payload::new(false);
assert!(req.urlencoded(payload).is_err());
let mut headers = HeaderMap::new();
headers.insert(header::CONTENT_TYPE,
header::HeaderValue::from_static("application/x-www-form-urlencoded"));
headers.insert(header::CONTENT_LENGTH,
header::HeaderValue::from_static("1000000"));
let req = HttpRequest::new(
Method::GET, Uri::try_from("/").unwrap(), Version::HTTP_11, headers);
let (_, payload) = Payload::new(false);
assert!(req.urlencoded(payload).is_err());
let mut headers = HeaderMap::new();
headers.insert(header::CONTENT_TYPE,
header::HeaderValue::from_static("text/plain"));
headers.insert(header::CONTENT_LENGTH,
header::HeaderValue::from_static("10"));
let req = HttpRequest::new(
Method::GET, Uri::try_from("/").unwrap(), Version::HTTP_11, headers);
let (_, payload) = Payload::new(false);
assert!(req.urlencoded(payload).is_err());
}
}