Skip to content

Commit

Permalink
use assert and restore test case
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Jul 15, 2018
1 parent c43b6e3 commit 2214492
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 10 additions & 6 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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);
}

Expand Down
6 changes: 3 additions & 3 deletions src/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2214492

Please sign in to comment.