xref: /openbmc/bmcweb/test/redfish-core/lib/thermal_subsystem_test.cpp (revision 40e9b92ec19acffb46f83a6e55b18974da5d708e)
1 // SPDX-License-Identifier: Apache-2.0
2 // SPDX-FileCopyrightText: Copyright OpenBMC Authors
3 #include "async_resp.hpp"
4 #include "http_response.hpp"
5 #include "thermal_subsystem.hpp"
6 
7 #include <nlohmann/json.hpp>
8 
9 #include <memory>
10 #include <optional>
11 #include <string>
12 
13 #include <gtest/gtest.h>
14 
15 namespace redfish
16 {
17 namespace
18 {
19 
20 constexpr const char* chassisId = "ChassisId";
21 constexpr const char* validChassisPath = "ChassisPath";
22 
assertThermalCollectionGet(crow::Response & res)23 void assertThermalCollectionGet(crow::Response& res)
24 {
25     nlohmann::json& json = res.jsonValue;
26     EXPECT_EQ(json["@odata.type"], "#ThermalSubsystem.v1_0_0.ThermalSubsystem");
27     EXPECT_EQ(json["Name"], "Thermal Subsystem");
28     EXPECT_EQ(json["Id"], "ThermalSubsystem");
29     EXPECT_EQ(json["@odata.id"],
30               "/redfish/v1/Chassis/ChassisId/ThermalSubsystem");
31     EXPECT_EQ(json["Status"]["State"], "Enabled");
32     EXPECT_EQ(json["Status"]["Health"], "OK");
33 }
34 
TEST(ThermalSubsystemCollectionTest,ThermalSubsystemCollectionStaticAttributesAreExpected)35 TEST(ThermalSubsystemCollectionTest,
36      ThermalSubsystemCollectionStaticAttributesAreExpected)
37 {
38     auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
39     shareAsyncResp->res.setCompleteRequestHandler(assertThermalCollectionGet);
40     doThermalSubsystemCollection(
41         shareAsyncResp, chassisId,
42         std::make_optional<std::string>(validChassisPath));
43 }
44 
45 } // namespace
46 } // namespace redfish
47