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