blob: 532148dff96ae2b2e38b60d8252269bfe4423c91 [file] [log] [blame]
#include "app.hpp"
#include "async_resp.hpp"
#include "assembly.hpp"
#include "chassis.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
#include "snapshot_fixture.hpp"
#include <nlohmann/json.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace redfish
{
namespace
{
TEST_F(SnapshotFixture, GetChassisAssmeblyReturnsTheCorrectResponse)
{
getChassisAssembly(app_, CreateRequest(), share_async_resp_, "platform1");
RunIoUntilDone();
LOG(INFO) << share_async_resp_->res.jsonValue.dump(2);
nlohmann::json& json = share_async_resp_->res.jsonValue;
EXPECT_EQ(json["@odata.id"], "/redfish/v1/Chassis/platform1/Assembly");
EXPECT_EQ(json["@odata.type"], "#Assembly.v1_3_0.Assembly");
EXPECT_EQ(json["Id"], "Assembly");
EXPECT_EQ(json["Name"], "Assembly Collection");
EXPECT_EQ(json["Assemblies"].size(), json["Assemblies@odata.count"]);
// Order should be CpuCooler0, CpuCooler1, tray
nlohmann::json& cpuCooler0 = json["Assemblies"][0];
EXPECT_EQ(cpuCooler0["@odata.id"], "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/0");
EXPECT_EQ(cpuCooler0["@odata.type"], "#Assembly.v1_3_0.AssemblyData");
EXPECT_EQ(cpuCooler0["Location"]["PartLocation"]["LocationType"], "Slot");
EXPECT_EQ(cpuCooler0["Location"]["PartLocation"]["ServiceLabel"], "CPU0_ANCHORS");
EXPECT_EQ(cpuCooler0["MemberId"], "0");
EXPECT_EQ(cpuCooler0["Model"], "Model");
EXPECT_EQ(cpuCooler0["Name"], "CpuCooler0");
nlohmann::json& cpuCooler1 = json["Assemblies"][1];
EXPECT_EQ(cpuCooler1["@odata.id"], "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/1");
EXPECT_EQ(cpuCooler1["@odata.type"], "#Assembly.v1_3_0.AssemblyData");
EXPECT_EQ(cpuCooler1["Location"]["PartLocation"]["LocationType"], "Slot");
EXPECT_EQ(cpuCooler1["Location"]["PartLocation"]["ServiceLabel"], "CPU1_ANCHORS");
EXPECT_EQ(cpuCooler1["MemberId"], "1");
EXPECT_EQ(cpuCooler1["Model"], "Model");
EXPECT_EQ(cpuCooler1["Name"], "CpuCooler1");
nlohmann::json& tray = json["Assemblies"][2];
EXPECT_EQ(tray["@odata.id"], "/redfish/v1/Chassis/platform1/Assembly#/Assemblies/2");
EXPECT_EQ(tray["@odata.type"], "#Assembly.v1_3_0.AssemblyData");
EXPECT_EQ(tray["Location"]["PartLocation"]["LocationType"], "Slot");
EXPECT_EQ(tray["Location"]["PartLocation"]["ServiceLabel"], "TRAY");
EXPECT_EQ(tray["MemberId"], "2");
EXPECT_EQ(tray["Name"], "tray");
EXPECT_EQ(share_async_resp_->res.result(), boost::beast::http::status::ok);
}
}
}