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 | { |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 11 | App app; |
| 12 | app.validate(); |
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 | { |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 20 | App app; |
| 21 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 22 | BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; }); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 23 | |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 24 | // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once |
| 25 | // it is fixed |
| 26 | // EXPECT_THAT(app.getRoutes(), |
| 27 | // testing::ElementsAre(testing::Pointee(std::string("/")))); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | // Tests that static urls are correctly passed |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 31 | TEST(GetRoutes, TestlotsOfRoutes) |
| 32 | { |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 33 | App app; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 34 | BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; }); |
| 35 | BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; }); |
| 36 | BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; }); |
| 37 | BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; }); |
| 38 | BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; }); |
| 39 | BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; }); |
Ed Tanous | b4a7bfa | 2017-04-04 17:23:00 -0700 | [diff] [blame] | 40 | |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 41 | app.validate(); |
| 42 | |
| 43 | // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once |
| 44 | // it is fixed |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 45 | EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre( |
Nan Zhou | 5ad7720 | 2022-06-13 22:33:55 +0000 | [diff] [blame^] | 46 | // testing::Pointee(std::string("/")), |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 47 | testing::Pointee(std::string("/foo")), |
| 48 | testing::Pointee(std::string("/bar")), |
| 49 | testing::Pointee(std::string("/baz")), |
| 50 | testing::Pointee(std::string("/boo")), |
| 51 | testing::Pointee(std::string("/moo")))); |
Ed Tanous | 04e438c | 2020-10-03 08:06:26 -0700 | [diff] [blame] | 52 | } |