diff --git a/.travis.yml b/.travis.yml index 67cd9d38..54a86aa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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" diff --git a/src/router.rs b/src/router.rs index 468cc236..fbdcbc08 100644 --- a/src/router.rs +++ b/src/router.rs @@ -211,9 +211,11 @@ impl Router { 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 Router { 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); } diff --git a/src/scope.rs b/src/scope.rs index d9502c94..a12bcafa 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -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);