regulators: Add Services to ActionEnvironment
Add Services& services to the ActionEnvironment constructor.
Add Services& getServices() to the ActionEnvironment class.
Add Services& services to the ActionEnvironment class.
Update the ActionEnvironment test for the new getServices() method.
Update classes that create an ActionEnvironment.
Update all affected testcases that create an ActionEnvironment.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I12ac9f301746965aa282b69432a71ad525739c9e
diff --git a/phosphor-regulators/test/actions/i2c_action_tests.cpp b/phosphor-regulators/test/actions/i2c_action_tests.cpp
index 07542f5..3c155cb 100644
--- a/phosphor-regulators/test/actions/i2c_action_tests.cpp
+++ b/phosphor-regulators/test/actions/i2c_action_tests.cpp
@@ -18,6 +18,7 @@
#include "i2c_action.hpp"
#include "i2c_interface.hpp"
#include "id_map.hpp"
+#include "mock_services.hpp"
#include "mocked_i2c_interface.hpp"
#include <memory>
@@ -64,14 +65,15 @@
EXPECT_CALL(*i2cInterface, isOpen).Times(1).WillOnce(Return(false));
EXPECT_CALL(*i2cInterface, open).Times(1);
- // Create Device, IDMap, ActionEnvironment, and I2CAction
+ // Create Device, IDMap, MockServices, ActionEnvironment, and I2CAction
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should succeed without an exception.
@@ -91,14 +93,15 @@
EXPECT_CALL(*i2cInterface, isOpen).Times(1).WillOnce(Return(true));
EXPECT_CALL(*i2cInterface, open).Times(0);
- // Create Device, IDMap, ActionEnvironment, and I2CAction
+ // Create Device, IDMap, MockServices, ActionEnvironment, and I2CAction
Device device{
"reg1", true,
"/xyz/openbmc_project/inventory/system/chassis/motherboard/reg1",
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should succeed without an exception.
@@ -112,9 +115,10 @@
// Test where fails: getting current device fails
try
{
- // Create IDMap, ActionEnvironment, and I2CAction
+ // Create IDMap, MockServices, ActionEnvironment, and I2CAction
IDMap idMap{};
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should throw an exception since "reg1" is not a
@@ -150,7 +154,8 @@
std::move(i2cInterface)};
IDMap idMap{};
idMap.addDevice(device);
- ActionEnvironment env{idMap, "reg1"};
+ MockServices services{};
+ ActionEnvironment env{idMap, "reg1", services};
I2CActionImpl action{};
// Get I2CInterface. Should throw an exception from the open() call.