| Alexander Hansen | 90e4f05 | 2025-10-10 22:58:01 +0200 | [diff] [blame] | 1 | |
| 2 | #include "entity_manager/log_device_inventory.hpp" |
| 3 | |
| 4 | #include <gtest/gtest.h> |
| 5 | |
| 6 | TEST(LogDevicInventory, QueryInvInfoSuccess) |
| 7 | { |
| 8 | nlohmann::json record = nlohmann::json::parse(R"( |
| 9 | { |
| 10 | "Name": "Supermicro PWS 920P SQ 0", |
| 11 | "Type": "PowerSupply", |
| 12 | "xyz.openbmc_project.Inventory.Decorator.Asset": { |
| 13 | "Manufacturer": "Supermicro", |
| 14 | "Model": "PWS 920P SQ", |
| 15 | "PartNumber": "328923", |
| 16 | "SerialNumber": "43829239" |
| 17 | } |
| 18 | } |
| 19 | )"); |
| 20 | |
| 21 | InvAddRemoveInfo info = queryInvInfo(record); |
| 22 | |
| 23 | EXPECT_EQ(info.name, "Supermicro PWS 920P SQ 0"); |
| 24 | EXPECT_EQ(info.type, "PowerSupply"); |
| 25 | EXPECT_EQ(info.sn, "43829239"); |
| 26 | EXPECT_EQ(info.model, "PWS 920P SQ"); |
| 27 | } |
| 28 | |
| 29 | TEST(LogDevicInventory, QueryInvInfoNoModelFound) |
| 30 | { |
| 31 | nlohmann::json record = nlohmann::json::parse(R"( |
| 32 | { |
| 33 | "Name": "Supermicro PWS 920P SQ 0", |
| 34 | "Type": "PowerSupply", |
| 35 | "xyz.openbmc_project.Inventory.Decorator.Asset": { |
| 36 | "Manufacturer": "Supermicro", |
| 37 | "PartNumber": "328923", |
| 38 | "SerialNumber": "43829239" |
| 39 | } |
| 40 | } |
| 41 | )"); |
| 42 | |
| 43 | InvAddRemoveInfo info = queryInvInfo(record); |
| 44 | |
| 45 | EXPECT_EQ(info.name, "Supermicro PWS 920P SQ 0"); |
| 46 | EXPECT_EQ(info.type, "PowerSupply"); |
| 47 | EXPECT_EQ(info.sn, "43829239"); |
| 48 | EXPECT_EQ(info.model, "Unknown"); |
| 49 | } |