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
diff --git a/test/include/google/google_service_root_test.cpp b/test/include/google/google_service_root_test.cpp
new file mode 100644
index 0000000..32d4e52
--- /dev/null
+++ b/test/include/google/google_service_root_test.cpp
@@ -0,0 +1,39 @@
+#include "async_resp.hpp"
+#include "google/google_service_root.hpp"
+#include "http_request.hpp"
+#include "nlohmann/json.hpp"
+
+#include <gtest/gtest.h>
+
+namespace crow::google_api
+{
+namespace
+{
+
+void validateServiceRootGet(crow::Response& res)
+{
+ nlohmann::json& json = res.jsonValue;
+ EXPECT_EQ(json["@odata.id"], "/google/v1");
+ EXPECT_EQ(json["@odata.type"],
+ "#GoogleServiceRoot.v1_0_0.GoogleServiceRoot");
+ EXPECT_EQ(json["@odata.id"], "/google/v1");
+ EXPECT_EQ(json["Id"], "Google Rest RootService");
+ EXPECT_EQ(json["Name"], "Google Service Root");
+ EXPECT_EQ(json["Version"], "1.0.0");
+ EXPECT_EQ(json["RootOfTrustCollection"]["@odata.id"],
+ "/google/v1/RootOfTrustCollection");
+}
+
+TEST(HandleGoogleV1Get, OnSuccess)
+{
+ std::error_code ec;
+ auto asyncResp = std::make_shared<bmcweb::AsyncResp>();
+
+ asyncResp->res.setCompleteRequestHandler(validateServiceRootGet);
+
+ crow::Request dummyRequest{{boost::beast::http::verb::get, "", 11}, ec};
+ handleGoogleV1Get(dummyRequest, asyncResp);
+}
+
+} // namespace
+} // namespace crow::google_api
\ No newline at end of file