Skip to content

Commit

Permalink
Update tests/router_test.cc
Browse files Browse the repository at this point in the history
Co-authored-by: Andrea Pappacoda <[email protected]>
  • Loading branch information
kiplingw and Tachi107 authored Apr 27, 2024
1 parent 8bd3683 commit 549f1f2
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/router_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,23 @@ TEST(router_test, test_remove_not_existing)
{
SegmentTreeNode routes;

ASSERT_THROW(routes.removeRoute("/v1/hello"), std::runtime_error);
ASSERT_THROW(routes.removeRoute("/v1/hello/:name/"), std::runtime_error);
ASSERT_THROW(routes.removeRoute("/get/:key?/bar"), std::runtime_error);
ASSERT_THROW(routes.removeRoute("/say/*/to/*"), std::runtime_error);
ASSERT_THROW(routes.removeRoute("*/api"), std::runtime_error);
using testing::ThrowsMessage;

ASSERT_THAT(
[&] { routes.removeRoute("/v1/hello"); },
ThrowsMessage<std::runtime_error>("Requested route does not exist."));
ASSERT_THAT(
[&] { routes.removeRoute("/v1/hello/:name/"); },
ThrowsMessage<std::runtime_error>("Requested route does not exist."));
ASSERT_THAT(
[&] { routes.removeRoute("/get/:key?/bar"); },
ThrowsMessage<std::runtime_error>("Requested route does not exist."));
ASSERT_THAT(
[&] { routes.removeRoute("/say/*/to/*"); },
ThrowsMessage<std::runtime_error>("Requested route does not exist."));
ASSERT_THAT(
[&] { routes.removeRoute("*/api"); },
ThrowsMessage<std::runtime_error>("Requested route does not exist."));
}

class MyHandler
Expand Down

0 comments on commit 549f1f2

Please sign in to comment.