From 58725df0804b1b3670160ab91b31089b5650fd93 Mon Sep 17 00:00:00 2001 From: kcudnik Date: Mon, 13 Sep 2021 11:37:38 +0200 Subject: [PATCH] Add ServerConfig tests --- unittest/lib/Makefile.am | 3 ++- unittest/lib/TestServerConfig.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 unittest/lib/TestServerConfig.cpp diff --git a/unittest/lib/Makefile.am b/unittest/lib/Makefile.am index 07a401608..4ed673bfc 100644 --- a/unittest/lib/Makefile.am +++ b/unittest/lib/Makefile.am @@ -18,7 +18,8 @@ tests_SOURCES = \ TestZeroMQChannel.cpp \ TestSwitchContainer.cpp \ TestSwitchConfigContainer.cpp \ - TestSkipRecordAttrContainer.cpp + TestSkipRecordAttrContainer.cpp \ + TestServerConfig.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS) diff --git a/unittest/lib/TestServerConfig.cpp b/unittest/lib/TestServerConfig.cpp new file mode 100644 index 000000000..76e372b4b --- /dev/null +++ b/unittest/lib/TestServerConfig.cpp @@ -0,0 +1,15 @@ +#include "ServerConfig.h" + +#include + +#include + +using namespace sairedis; + +TEST(ServerConfig, loadFromFile) +{ + EXPECT_NE(ServerConfig::loadFromFile("/not_existing"), nullptr); + + EXPECT_NE(ServerConfig::loadFromFile("files/server_config_ok.json"), nullptr); + EXPECT_NE(ServerConfig::loadFromFile("files/server_config_bad.json"), nullptr); +}