-
Notifications
You must be signed in to change notification settings - Fork 543
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stepan Blyschak <stepanb@nvidia.com>
- Loading branch information
1 parent
dfd360d
commit 235bbde
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
tests/mock_tests/response_publisher/response_publisher_ut.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "response_publisher.h" | ||
|
||
#include <gtest/gtest.h> | ||
|
||
bool gResponsePublisherRecord{false}; | ||
bool gResponsePublisherLogRotate{false}; | ||
std::ofstream gResponsePublisherRecordOfs; | ||
std::string gResponsePublisherRecordFile; | ||
|
||
using namespace swss; | ||
|
||
TEST(ResponsePublisher, TestPublish) | ||
{ | ||
DBConnector conn{"APPL_STATE_DB", 0}; | ||
Table stateTable{&conn, "SOME_TABLE"}; | ||
std::string value; | ||
ResponsePublisher publisher{}; | ||
|
||
publisher.publish("SOME_TABLE", "SOME_KEY", {{"field", "value"}}, ReturnCode(SAI_STATUS_SUCCESS)); | ||
ASSERT_TRUE(stateTable.hget("SOME_KEY", "field", value)); | ||
ASSERT_EQ(value, "value"); | ||
} | ||
|
||
TEST(ResponsePublisher, TestPublishBuffered) | ||
{ | ||
DBConnector conn{"APPL_STATE_DB", 0}; | ||
Table stateTable{&conn, "SOME_TABLE"}; | ||
std::string value; | ||
ResponsePublisher publisher{}; | ||
|
||
publisher.setBuffered(true); | ||
|
||
publisher.publish("SOME_TABLE", "SOME_KEY", {{"field", "value"}}, ReturnCode(SAI_STATUS_SUCCESS)); | ||
publisher.flush(); | ||
ASSERT_TRUE(stateTable.hget("SOME_KEY", "field", value)); | ||
ASSERT_EQ(value, "value"); | ||
} |