Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 1 | #include <crow/app.h> |
| 2 | #include "gmock/gmock.h" |
| 3 | #include "gtest/gtest.h" |
| 4 | |
| 5 | using namespace crow; |
| 6 | using namespace std; |
| 7 | |
| 8 | TEST(GetRoutes, TestEmptyRoutes) { |
| 9 | SimpleApp app; |
| 10 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
| 11 | |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 12 | EXPECT_THAT(app.getRoutes(), testing::IsEmpty()); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 13 | } |
| 14 | |
| 15 | // Tests that static urls are correctly passed |
| 16 | TEST(GetRoutes, TestOneRoute) { |
| 17 | SimpleApp app; |
| 18 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 19 | BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; }); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 20 | |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 21 | EXPECT_THAT(app.getRoutes(), |
Ed Tanous | 1c74de8 | 2017-10-26 13:58:28 -0700 | [diff] [blame] | 22 | testing::ElementsAre(testing::Pointee(std::string("/")))); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | // Tests that static urls are correctly passed |
| 26 | TEST(GetRoutes, TestlotsOfRoutes) { |
| 27 | SimpleApp app; |
| 28 | decltype(app)::server_t server(&app, "127.0.0.1", 45451); |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 29 | BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; }); |
| 30 | BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; }); |
| 31 | BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; }); |
| 32 | BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; }); |
| 33 | BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; }); |
| 34 | BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; }); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 35 | |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 36 | EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre( |
| 37 | testing::Pointee(std::string("/")), |
| 38 | testing::Pointee(std::string("/foo")), |
| 39 | testing::Pointee(std::string("/bar")), |
| 40 | testing::Pointee(std::string("/baz")), |
| 41 | testing::Pointee(std::string("/boo")), |
| 42 | testing::Pointee(std::string("/moo")))); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 43 | } |