regulators: Modify close() to use services
Modify the Device::close() method in the Device class to have a new
first parameter: Services& services.
Modify Device::close() to log messages using the new Journal
interface.
Modify the Chassis::closeDevices() method in the Chassis class to
have a new first parameter: Services& services.
Modify Chassis::closeDevices() to log messages using the new
Journal interface.
Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I2a07417d6f7470685f2c27c878ef7936e9f1aa8a
diff --git a/phosphor-regulators/test/system_tests.cpp b/phosphor-regulators/test/system_tests.cpp
index 5d1d720..809d2d4 100644
--- a/phosphor-regulators/test/system_tests.cpp
+++ b/phosphor-regulators/test/system_tests.cpp
@@ -71,6 +71,14 @@
// Specify an empty rules vector
std::vector<std::unique_ptr<Rule>> rules{};
+ // Create mock services. Expect logDebug() to be called.
+ MockServices services{};
+ MockJournal& journal = services.getMockJournal();
+ EXPECT_CALL(journal, logDebug("Closing devices in chassis 1")).Times(1);
+ EXPECT_CALL(journal, logDebug("Closing devices in chassis 3")).Times(1);
+ EXPECT_CALL(journal, logInfo(A<const std::string&>())).Times(0);
+ EXPECT_CALL(journal, logError(A<const std::string&>())).Times(0);
+
// Create Chassis
std::vector<std::unique_ptr<Chassis>> chassis{};
chassis.emplace_back(std::make_unique<Chassis>(1));
@@ -80,13 +88,7 @@
System system{std::move(rules), std::move(chassis)};
// Call closeDevices()
- journal::clear();
- system.closeDevices();
- EXPECT_EQ(journal::getErrMessages().size(), 0);
- EXPECT_EQ(journal::getInfoMessages().size(), 0);
- std::vector<std::string> expectedDebugMessages{
- "Closing devices in chassis 1", "Closing devices in chassis 3"};
- EXPECT_EQ(journal::getDebugMessages(), expectedDebugMessages);
+ system.closeDevices(services);
}
TEST(SystemTests, Configure)