Skip to content

Commit

Permalink
Get back mock as it is used by other tests
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Blyschak <[email protected]>
  • Loading branch information
stepanblyschak committed May 17, 2024
1 parent a4f2bd8 commit 4607220
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/mock_tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ tests_intfmgrd_INCLUDES = $(tests_INCLUDES) -I$(top_srcdir)/cfgmgr -I$(top_srcdi
tests_intfmgrd_CFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI)
tests_intfmgrd_CPPFLAGS = $(DBGFLAGS) $(AM_CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_GTEST) $(CFLAGS_SAI) $(tests_intfmgrd_INCLUDES)
tests_intfmgrd_LDADD = $(LDADD_GTEST) $(LDADD_SAI) -lnl-genl-3 -lhiredis -lhiredis \
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread
-lswsscommon -lswsscommon -lgtest -lgtest_main -lzmq -lnl-3 -lnl-route-3 -lpthread -lgmock -lgmock_main

## teammgrd unit tests

Expand Down
21 changes: 19 additions & 2 deletions tests/mock_tests/fake_response_publisher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#include <vector>

#include "response_publisher.h"
#include "mock_response_publisher.h"

/* This mock plugs into this fake response publisher implementation
* when needed to test code that uses response publisher. */
std::unique_ptr<MockResponsePublisher> gMockResponsePublisher;

ResponsePublisher::ResponsePublisher(const std::string& dbName, bool buffered, bool db_write_thread) :
m_db(std::make_unique<swss::DBConnector>(dbName, 0)), m_buffered(buffered) {}
Expand All @@ -12,12 +17,24 @@ void ResponsePublisher::publish(
const std::string& table, const std::string& key,
const std::vector<swss::FieldValueTuple>& intent_attrs,
const ReturnCode& status,
const std::vector<swss::FieldValueTuple>& state_attrs, bool replace) {}
const std::vector<swss::FieldValueTuple>& state_attrs, bool replace)
{
if (gMockResponsePublisher)
{
gMockResponsePublisher->publish(table, key, intent_attrs, status, state_attrs, replace);
}
}

void ResponsePublisher::publish(
const std::string& table, const std::string& key,
const std::vector<swss::FieldValueTuple>& intent_attrs,
const ReturnCode& status, bool replace) {}
const ReturnCode& status, bool replace)
{
if (gMockResponsePublisher)
{
gMockResponsePublisher->publish(table, key, intent_attrs, status, replace);
}
}

void ResponsePublisher::writeToDB(
const std::string& table, const std::string& key,
Expand Down

0 comments on commit 4607220

Please sign in to comment.