blob: dc6e427e7aa5b94e045aa8f4ea29261ed93c73d3 [file] [log] [blame]
#include "app.hpp"
#include "async_resp.hpp"
#include "http_request.hpp"
#include <memory>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace crow
{
namespace
{
using ::bmcweb::AsyncResp;
using ::testing::Eq;
using ::testing::IsEmpty;
using ::testing::Pointee;
using ::testing::UnorderedElementsAre;
TEST(GetRoutes, TestEmptyRoutes)
{
App app;
app.validate();
EXPECT_THAT(app.getRoutes(), IsEmpty());
}
// Tests that static urls are correctly passed
TEST(GetRoutes, TestOneRoute)
{
App app;
BMCWEB_ROUTE(app, "/")
([](const crow::Request& /*req*/,
const std::shared_ptr<AsyncResp>& /*asyncResp*/) {});
// TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
// it is fixed
// EXPECT_THAT(app.getRoutes(),
// testing::ElementsAre(Pointee(Eq("/"))));
}
// Tests that static urls are correctly passed
TEST(GetRoutes, TestlotsOfRoutes)
{
App app;
BMCWEB_ROUTE(app, "/")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
BMCWEB_ROUTE(app, "/foo")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
BMCWEB_ROUTE(app, "/bar")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
BMCWEB_ROUTE(app, "/baz")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
BMCWEB_ROUTE(app, "/boo")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
BMCWEB_ROUTE(app, "/moo")
([](const Request& /*req*/, const std::shared_ptr<AsyncResp>& /*res*/) {});
app.validate();
// TODO: "/" doesn't get reported in |getRoutes| today. Uncomment this once
// it is fixed
EXPECT_THAT(app.getRoutes(), UnorderedElementsAre(
// Pointee(Eq("/")),
Pointee(Eq("/foo")), Pointee(Eq("/bar")),
Pointee(Eq("/baz")), Pointee(Eq("/boo")),
Pointee(Eq("/moo"))));
}
} // namespace
} // namespace crow