diff options
author | Nan Zhou <nanzhoumails@gmail.com> | 2022-09-10 21:11:41 +0300 |
---|---|---|
committer | Nan Zhou <nanzhoumails@gmail.com> | 2022-09-22 02:44:37 +0300 |
commit | c33a039b56fc5789ae71289adaca1e572a48d318 (patch) | |
tree | 8b936ca291537cebebf6bf505e565bff9635f511 /src | |
parent | 6ab9ad5492b9203c7dd8fb3e8c59d37bbc455cde (diff) | |
download | bmcweb-c33a039b56fc5789ae71289adaca1e572a48d318.tar.xz |
treewide: reorganize unit tests
Like other C++ projects, unit tests normally are in a separate repo and
respect the folder structure of the file under test.
This commit deleted all "ut" folder and move tests to a "test" folder.
The test folder also has similar structure as the main folder.
This commit also made neccessary include changes to make codes compile.
Unused tests are untouched.
Tested: unit test passed.
Reference:
[1] https://github.com/grpc/grpc/tree/master/test
[2] https://github.com/boostorg/core/tree/414dfb466878af427d33b36e6ccf84d21c0e081b/test
[3] Many other OpenBMC repos: https://github.com/openbmc/entity-manager/tree/master/test
[4] https://stackoverflow.com/questions/2360734/whats-a-good-directory-structure-for-larger-c-projects-using-makefile
Signed-off-by: Nan Zhou <nanzhoumails@gmail.com>
Change-Id: I4521c7ef5fa03c47cca5c146d322bbb51365ee96
Diffstat (limited to 'src')
-rw-r--r-- | src/crow_getroutes_test.cpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp deleted file mode 100644 index 23a511e735..0000000000 --- a/src/crow_getroutes_test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "app.hpp" -#include "routing.hpp" - -#include <boost/beast/http/status.hpp> - -#include <memory> - -#include <gmock/gmock.h> // IWYU pragma: keep -#include <gtest/gtest.h> // IWYU pragma: keep - -// IWYU pragma: no_include <gtest/gtest-message.h> -// IWYU pragma: no_include <gtest/gtest-test-part.h> -// IWYU pragma: no_include "gtest/gtest_pred_impl.h" -// IWYU pragma: no_include <gmock/gmock-matchers.h> -// IWYU pragma: no_include <gmock/gmock-more-matchers.h> -// IWYU pragma: no_include <gtest/gtest-matchers.h> - -namespace crow -{ -namespace -{ - -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, "/")([]() { return boost::beast::http::status::ok; }); - - // 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, "/")([]() { 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; }); - BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; }); - 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(), UnorderedElementsAre( - // Pointee(Eq("/")), - Pointee(Eq("/foo")), Pointee(Eq("/bar")), - Pointee(Eq("/baz")), Pointee(Eq("/boo")), - Pointee(Eq("/moo")))); -} -} // namespace -} // namespace crow |