blob: 0ea36401f27ed4569d50c0d370e37a37c277dcc4 [file] [log] [blame]
Lei YU12c9f4c2019-09-11 15:08:15 +08001#include "activation.hpp"
2
3#include <sdbusplus/test/sdbus_mock.hpp>
4
5#include <gmock/gmock.h>
6#include <gtest/gtest.h>
7
8using namespace phosphor::software::updater;
9
10class 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
31TEST_F(TestActivation, ctordtor)
32{
33 activation = std::make_unique<Activation>(mockedBus, dBusPath, versionId,
34 extVersion, status, associations);
35}
36
37namespace phosphor::software::updater::internal
38{
39extern std::string getUpdateService(const std::string& psuInventoryPath,
40 const std::string& versionId);
41}
42
43TEST_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}