blob: 29052a9a21f76c0ce0f432ae3a47f7d8efc306c0 [file] [log] [blame]
Ed Tanousb4a7bfa2017-04-04 17:23:00 -07001#include <crow/app.h>
2#include "gmock/gmock.h"
3#include "gtest/gtest.h"
4
5using namespace crow;
6using namespace std;
7
8TEST(GetRoutes, TestEmptyRoutes) {
9 SimpleApp app;
10 decltype(app)::server_t server(&app, "127.0.0.1", 45451);
11
Ed Tanous55c7b7a2018-05-22 15:27:24 -070012 EXPECT_THAT(app.getRoutes(), testing::IsEmpty());
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070013}
14
15// Tests that static urls are correctly passed
16TEST(GetRoutes, TestOneRoute) {
17 SimpleApp app;
18 decltype(app)::server_t server(&app, "127.0.0.1", 45451);
Ed Tanous55c7b7a2018-05-22 15:27:24 -070019 BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070020
Ed Tanous55c7b7a2018-05-22 15:27:24 -070021 EXPECT_THAT(app.getRoutes(),
Ed Tanous1c74de82017-10-26 13:58:28 -070022 testing::ElementsAre(testing::Pointee(std::string("/"))));
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070023}
24
25// Tests that static urls are correctly passed
26TEST(GetRoutes, TestlotsOfRoutes) {
27 SimpleApp app;
28 decltype(app)::server_t server(&app, "127.0.0.1", 45451);
Ed Tanous55c7b7a2018-05-22 15:27:24 -070029 BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
30 BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; });
31 BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; });
32 BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; });
33 BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; });
34 BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; });
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070035
Ed Tanous55c7b7a2018-05-22 15:27:24 -070036 EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre(
37 testing::Pointee(std::string("/")),
38 testing::Pointee(std::string("/foo")),
39 testing::Pointee(std::string("/bar")),
40 testing::Pointee(std::string("/baz")),
41 testing::Pointee(std::string("/boo")),
42 testing::Pointee(std::string("/moo"))));
Ed Tanousb4a7bfa2017-04-04 17:23:00 -070043}