summaryrefslogtreecommitdiff
path: root/test/redfish-core/lib/power_subsystem_test.cpp
blob: 1dfbbeb3ffe2e837ad2f004ff15db8198c15ff53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "async_resp.hpp"
#include "power_subsystem.hpp"

#include <nlohmann/json.hpp>

#include <optional>
#include <string>

#include <gtest/gtest.h>

namespace redfish
{
namespace
{

constexpr const char* chassisId = "ChassisId";
constexpr const char* validChassisPath = "ChassisPath";

void assertPowerSubsystemCollectionGet(crow::Response& res)
{
    nlohmann::json& json = res.jsonValue;
    EXPECT_EQ(json["@odata.type"], "#PowerSubsystem.v1_1_0.PowerSubsystem");
    EXPECT_EQ(json["Name"], "Power Subsystem");
    EXPECT_EQ(json["Id"], "PowerSubsystem");
    EXPECT_EQ(json["@odata.id"],
              "/redfish/v1/Chassis/ChassisId/PowerSubsystem");
    EXPECT_EQ(json["Status"]["State"], "Enabled");
    EXPECT_EQ(json["Status"]["Health"], "OK");
}

TEST(PowerSubsystemCollectionTest,
     PowerSubsystemCollectionStaticAttributesAreExpected)
{
    auto shareAsyncResp = std::make_shared<bmcweb::AsyncResp>();
    shareAsyncResp->res.setCompleteRequestHandler(
        assertPowerSubsystemCollectionGet);
    doPowerSubsystemCollection(
        shareAsyncResp, chassisId,
        std::make_optional<std::string>(validChassisPath));
}

} // namespace
} // namespace redfish