Skip to content

Commit aee6395

Browse files
Add missing mock call expectations
`CmdShowRouteDetailsTest` was complaing about some unexpected calls: ``` GMOCK WARNING: Uninteresting mock function call - returning directly. Function call: getAllPortInfo(@0x7f8d0c000b10 {}) NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md#knowing-when-to-expect for details. GMOCK WARNING: Uninteresting mock function call - returning directly. Function call: getAggregatePortTable(@0x7f8d04001120 {}) NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md#knowing-when-to-expect for details. GMOCK WARNING: Uninteresting mock function call - returning directly. Function call: getAllPortInfo(@0x7f8d2d100c20 {}) NOTE: You can safely ignore the above warning unless this call should not happen. Do not suppress it by blindly adding an EXPECT_CALL() if you don't mean to enforce the call. See https://github.com/google/googletest/blob/master/docs/gmock_cook_book.md#knowing-when-to-expect for details. ```
1 parent 88c4089 commit aee6395

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

fboss/cli/fboss2/test/CmdShowRouteDetailsTest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ TEST_F(CmdShowRouteDetailsTestFixture, queryClient) {
193193
setupMockedAgentServer();
194194
EXPECT_CALL(getMockAgent(), getRouteTableDetails(_))
195195
.WillOnce(Invoke([&](auto& entries) { entries = routeEntries; }));
196+
// Mock the calls made by populateAggregatePortMap and populateVlanPortMap
197+
EXPECT_CALL(getMockAgent(), getAllPortInfo(_))
198+
.Times(2)
199+
.WillRepeatedly(Invoke([&](auto& entries) { entries.clear(); }));
200+
EXPECT_CALL(getMockAgent(), getAggregatePortTable(_))
201+
.WillOnce(Invoke([&](auto& entries) { entries.clear(); }));
196202

197203
auto cmd = CmdShowRouteDetails();
198204
CmdShowRouteDetailsTraits::ObjectArgType queriedEntries;
@@ -205,6 +211,12 @@ TEST_F(CmdShowRouteDetailsTestFixture, queryNetworkEntries) {
205211
setupMockedAgentServer();
206212
EXPECT_CALL(getMockAgent(), getRouteTableDetails(_))
207213
.WillOnce(Invoke([&](auto& entries) { entries = routeEntries; }));
214+
// Mock the calls made by populateAggregatePortMap and populateVlanPortMap
215+
EXPECT_CALL(getMockAgent(), getAllPortInfo(_))
216+
.Times(2)
217+
.WillRepeatedly(Invoke([&](auto& entries) { entries.clear(); }));
218+
EXPECT_CALL(getMockAgent(), getAggregatePortTable(_))
219+
.WillOnce(Invoke([&](auto& entries) { entries.clear(); }));
208220

209221
auto cmd = CmdShowRouteDetails();
210222
std::vector<std::string> entries = {"2401:db00::/32", "176.161.6.0/32"};
@@ -221,6 +233,12 @@ TEST_F(CmdShowRouteDetailsTestFixture, queryIpRouteEntries) {
221233
EXPECT_CALL(getMockAgent(), getIpRouteDetails(_, _, _))
222234
.WillOnce(
223235
Invoke([&](auto& entry, auto, auto) { entry = routeEntries[0]; }));
236+
// Mock the calls made by populateAggregatePortMap and populateVlanPortMap
237+
EXPECT_CALL(getMockAgent(), getAllPortInfo(_))
238+
.Times(2)
239+
.WillRepeatedly(Invoke([&](auto& entries) { entries.clear(); }));
240+
EXPECT_CALL(getMockAgent(), getAggregatePortTable(_))
241+
.WillOnce(Invoke([&](auto& entries) { entries.clear(); }));
224242

225243
auto cmd = CmdShowRouteDetails();
226244
std::vector<std::string> entries = {

0 commit comments

Comments
 (0)