blob: 47edf382811ac88299e588fe3d35e37c084697d2 [file] [log] [blame]
#include "app.hpp"
#include "async_resp.hpp"
#include "http_request.hpp"
#include "http_response.hpp"
#include "pcie.hpp"
#include "snapshot_fixture.hpp"
#include <nlohmann/json.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
namespace redfish
{
namespace
{
TEST_F(SnapshotFixture_Platform5_Config7, GetPCIeDeviceSuccess)
{
handleSystemPCIeDeviceGet(app_, CreateRequest(), share_async_resp_, "system",
"chassis8_1_Link_0");
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/Systems/system/PCIeDevices/chassis8_1_Link_0");
EXPECT_EQ(json["@odata.type"], "#PCIeDevice.v1_4_0.PCIeDevice");
EXPECT_EQ(json["Id"], "chassis8_1_Link_0");
EXPECT_EQ(json["Name"], "PCIe Device");
EXPECT_EQ(json["Manufacturer"], "Manufacturer");
EXPECT_EQ(json["DeviceType"], "SingleFunction");
nlohmann::json& functions = json["PCIeFunctions"];
EXPECT_EQ(functions["@odata.id"],
"/redfish/v1/Systems/system/PCIeDevices/chassis8_1_Link_0/PCIeFunctions");
nlohmann::json& interface = json["PCIeInterface"];
EXPECT_EQ(interface.size(), 2);
EXPECT_EQ(interface["PCIeType"], "Gen5");
EXPECT_EQ(interface["LanesInUse"], 8);
nlohmann::json& chassis = json["Links"]["Chassis"];
EXPECT_EQ(chassis.size(), 1);
EXPECT_EQ(chassis["@odata.id"], "/redfish/v1/Chassis/chassis8_1");
EXPECT_EQ(share_async_resp_->res.result(), boost::beast::http::status::ok);
}
TEST_F(SnapshotFixture_Platform5_Config7, GetPCIeDeviceMissing)
{
handleSystemPCIeDeviceGet(app_, CreateRequest(), share_async_resp_, "system",
"missing");
RunIoUntilDone();
LOG(INFO) << share_async_resp_->res.jsonValue.dump(2);
EXPECT_EQ(share_async_resp_->res.result(),
boost::beast::http::status::not_found);
}
TEST_F(SnapshotFixture_Platform5_Config7, GetPCIeDeviceWrongSystem)
{
handleSystemPCIeDeviceGet(app_, CreateRequest(), share_async_resp_, "asdf",
"chassis8_1_Link_0");
RunIoUntilDone();
LOG(INFO) << share_async_resp_->res.jsonValue.dump(2);
EXPECT_EQ(share_async_resp_->res.result(),
boost::beast::http::status::not_found);
}
} // namespace
} // namespace redfish