crow_getroutes_test: revive the test
The test today exists but it isn't enabled. This commit revives the
test, and fixed obsolete interfaces.
Note that the current codes don't return the "/" route correctly. This
commit doesn't fix it but left a TODO.
Tested: unit test passed
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: Ie5be7f545f1930ddb2c01b829d8de2e312e936dc
diff --git a/meson.build b/meson.build
index 8724c62..aa0fb3b 100644
--- a/meson.build
+++ b/meson.build
@@ -398,6 +398,7 @@
'redfish-core/ut/registries_test.cpp',
'redfish-core/ut/stl_utils_test.cpp',
'redfish-core/ut/time_utils_test.cpp',
+ 'src/crow_getroutes_test.cpp',
]
if(get_option('tests').enabled())
diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp
index eea045c..5352165 100644
--- a/src/crow_getroutes_test.cpp
+++ b/src/crow_getroutes_test.cpp
@@ -8,8 +8,8 @@
TEST(GetRoutes, TestEmptyRoutes)
{
- SimpleApp app;
- decltype(app)::server_t server(&app, "127.0.0.1", 45451);
+ App app;
+ app.validate();
EXPECT_THAT(app.getRoutes(), testing::IsEmpty());
}
@@ -17,19 +17,20 @@
// Tests that static urls are correctly passed
TEST(GetRoutes, TestOneRoute)
{
- SimpleApp app;
- decltype(app)::server_t server(&app, "127.0.0.1", 45451);
+ App app;
+
BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
- EXPECT_THAT(app.getRoutes(),
- testing::ElementsAre(testing::Pointee(std::string("/"))));
+ // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
+ // it is fixed
+ // EXPECT_THAT(app.getRoutes(),
+ // testing::ElementsAre(testing::Pointee(std::string("/"))));
}
// Tests that static urls are correctly passed
TEST(GetRoutes, TestlotsOfRoutes)
{
- SimpleApp app;
- decltype(app)::server_t server(&app, "127.0.0.1", 45451);
+ App app;
BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; });
BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; });
@@ -37,8 +38,12 @@
BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; });
BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; });
+ app.validate();
+
+ // TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
+ // it is fixed
EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre(
- testing::Pointee(std::string("/")),
+ // testing::Pointee(std::string("/")),
testing::Pointee(std::string("/foo")),
testing::Pointee(std::string("/bar")),
testing::Pointee(std::string("/baz")),