Lei YU | 12c9f4c | 2019-09-11 15:08:15 +0800 | [diff] [blame] | 1 | #include "activation.hpp" |
| 2 | |
| 3 | #include <sdbusplus/test/sdbus_mock.hpp> |
| 4 | |
| 5 | #include <gmock/gmock.h> |
| 6 | #include <gtest/gtest.h> |
| 7 | |
| 8 | using namespace phosphor::software::updater; |
| 9 | |
| 10 | class TestActivation : public ::testing::Test |
| 11 | { |
| 12 | public: |
| 13 | using ActivationStatus = sdbusplus::xyz::openbmc_project::Software::server:: |
| 14 | Activation::Activations; |
| 15 | TestActivation() |
| 16 | { |
| 17 | } |
| 18 | ~TestActivation() |
| 19 | { |
| 20 | } |
| 21 | static constexpr auto dBusPath = SOFTWARE_OBJPATH; |
| 22 | sdbusplus::SdBusMock sdbusMock; |
| 23 | sdbusplus::bus::bus mockedBus = sdbusplus::get_mocked_new(&sdbusMock); |
| 24 | std::unique_ptr<Activation> activation; |
| 25 | std::string versionId = "abcdefgh"; |
| 26 | std::string extVersion = "Some Ext Version"; |
| 27 | ActivationStatus status = ActivationStatus::Active; |
| 28 | AssociationList associations; |
| 29 | }; |
| 30 | |
| 31 | TEST_F(TestActivation, ctordtor) |
| 32 | { |
| 33 | activation = std::make_unique<Activation>(mockedBus, dBusPath, versionId, |
| 34 | extVersion, status, associations); |
| 35 | } |
| 36 | |
| 37 | namespace phosphor::software::updater::internal |
| 38 | { |
| 39 | extern std::string getUpdateService(const std::string& psuInventoryPath, |
| 40 | const std::string& versionId); |
| 41 | } |
| 42 | |
| 43 | TEST_F(TestActivation, getUpdateService) |
| 44 | { |
| 45 | std::string psuInventoryPath = "/com/example/inventory/powersupply1"; |
| 46 | std::string versionId = "12345678"; |
| 47 | std::string toCompare = "psu-update@-com-example-inventory-" |
| 48 | "powersupply1\\x20-tmp-images-12345678.service"; |
| 49 | |
| 50 | auto service = phosphor::software::updater::internal::getUpdateService( |
| 51 | psuInventoryPath, versionId); |
| 52 | EXPECT_EQ(toCompare, service); |
| 53 | } |