1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-27 17:52:56 +01:00

use assert and restore test case

This commit is contained in:
Nikolay Kim 2018-07-15 18:53:02 +06:00
parent c43b6e3577
commit 2214492792
3 changed files with 14 additions and 10 deletions

View File

@ -36,7 +36,7 @@ script:
fi
- |
if [[ "$TRAVIS_RUST_VERSION" == "stable" ]]; then
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin
RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install -f cargo-tarpaulin
cargo tarpaulin --features="alpn,tls" --out Xml --no-count
bash <(curl -s https://codecov.io/bash)
echo "Uploaded code coverage"

View File

@ -211,9 +211,11 @@ impl<S: 'static> Router<S> {
let name = resource.get_name();
if !name.is_empty() {
if inner.named.contains_key(name) {
panic!("Named resource {:?} is registered.", name);
}
assert!(
!inner.named.contains_key(name),
"Named resource {:?} is registered.",
name
);
inner.named.insert(name.to_owned(), resource.rdef().clone());
}
inner.patterns.push(resource.rdef().clone());
@ -279,9 +281,11 @@ impl<S: 'static> Router<S> {
pub(crate) fn register_external(&mut self, name: &str, rdef: ResourceDef) {
let inner = Rc::get_mut(&mut self.defs).unwrap();
if inner.named.contains_key(name) {
panic!("Named resource {:?} is registered.", name);
}
assert!(
!inner.named.contains_key(name),
"Named resource {:?} is registered.",
name
);
inner.named.insert(name.to_owned(), rdef);
}

View File

@ -910,9 +910,9 @@ mod tests {
})
.finish();
//let req = TestRequest::with_uri("/app/t1").request();
//let resp = app.run(req);
//assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
let req = TestRequest::with_uri("/app/t1").request();
let resp = app.run(req);
assert_eq!(resp.as_msg().status(), StatusCode::NOT_FOUND);
let req = TestRequest::with_uri("/app/t1/").request();
let resp = app.run(req);