| #include "http_response.hpp" |
| #include "test/redfish-core/lib/snapshot_fixture.hpp" |
| |
| #include <nlohmann/json.hpp> |
| |
| #include <gmock/gmock.h> |
| #include <gtest/gtest.h> |
| |
| namespace redfish |
| { |
| namespace |
| { |
| |
| using ::testing::Contains; |
| using ::testing::IsEmpty; |
| using ::testing::Not; |
| |
| TEST_F(SnapshotFixture, TimetraceToJson) |
| { |
| crow::Response response = crow::Response(); |
| |
| response.startTimetrace("TEST"); |
| |
| response.requestStartTime("test/request"); |
| response.requestEndTime(); |
| |
| response.endTimetrace("TEST"); |
| |
| nlohmann::json timetraceJson = response.timetraceToJson(); |
| |
| ASSERT_TRUE(timetraceJson["starttime"] <= timetraceJson["endtime"]); |
| EXPECT_EQ(timetraceJson["uri"], "test/request"); |
| EXPECT_THAT(timetraceJson["hops"], Not(IsEmpty())); |
| |
| } |
| |
| } // namespace |
| } // namespace redfish |