Skip to content

Commit

Permalink
test(inventory): check delta message on delete operation
Browse files Browse the repository at this point in the history
  • Loading branch information
vikman90 committed Dec 11, 2024
1 parent 32d00f2 commit 34cf92b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/modules/inventory/tests/inventory/inventory_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,32 @@ TEST_F(InventoryTest, SendUpdateEvent) {
inventory.SendDeltaEvent(inputData);
}

TEST_F(InventoryTest, SendDeleteEvent) {
::testing::MockFunction<int(const Message&)> mockPushMessage;

inventory.SetPushMessageFunction(mockPushMessage.AsStdFunction());

EXPECT_CALL(mockPushMessage, Call(::testing::_))
.WillOnce([](const Message& msg)
{
auto expectedData = R"({})";
auto expectedMetadata = R"({"id":"123","module":"inventory","operation":"delete","type":"hardware"})";

EXPECT_EQ(msg.data.dump(), expectedData);
EXPECT_EQ(msg.metaData, expectedMetadata);
return 1;
});

auto inputData = R"({
"type": "hardware",
"operation": "delete",
"id": "123",
"data": {"key": "value"}
})";

inventory.SendDeltaEvent(inputData);
}

int main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
Expand Down

0 comments on commit 34cf92b

Please sign in to comment.