blob: eea045c64c364558b43d039ecab9fa8faf20a1a7 [file] [log] [blame]
Ed Tanous04e438c2020-10-03 08:06:26 -07001#include <app.hpp>
Ed Tanous1abe55e2018-09-05 08:30:59 -07002
Ed Tanousb4a7bfa2017-04-04 17:23:00 -07003#include "gmock/gmock.h"
4#include "gtest/gtest.h"
5
6using namespace crow;
7using namespace std;
8
Ed Tanous1abe55e2018-09-05 08:30:59 -07009TEST(GetRoutes, TestEmptyRoutes)
10{
11 SimpleApp app;
12 decltype(app)::server_t server(&app, "127.0.0.1", 45451);
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070013
Ed Tanous1abe55e2018-09-05 08:30:59 -070014 EXPECT_THAT(app.getRoutes(), testing::IsEmpty());
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070015}
16
17// Tests that static urls are correctly passed
Ed Tanous1abe55e2018-09-05 08:30:59 -070018TEST(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 Tanousb4a7bfa2017-04-04 17:23:00 -070023
Ed Tanous1abe55e2018-09-05 08:30:59 -070024 EXPECT_THAT(app.getRoutes(),
25 testing::ElementsAre(testing::Pointee(std::string("/"))));
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070026}
27
28// Tests that static urls are correctly passed
Ed Tanous1abe55e2018-09-05 08:30:59 -070029TEST(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 Tanousb4a7bfa2017-04-04 17:23:00 -070039
Ed Tanous1abe55e2018-09-05 08:30:59 -070040 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 Tanous04e438c2020-10-03 08:06:26 -070047}