Commit 5e35336e authored by Francis Dupont's avatar Francis Dupont

[406-update-cb_cmds-with-get-commands] Moved testutils and use runToElementTest

parent 2d0d9f8b
# The following build order must be maintained. # The following build order must be maintained.
SUBDIRS = exceptions util log cryptolink dns asiolink cc database SUBDIRS = exceptions util log cryptolink dns asiolink cc testutils database
if HAVE_MYSQL if HAVE_MYSQL
SUBDIRS += mysql SUBDIRS += mysql
...@@ -13,7 +13,7 @@ if HAVE_CQL ...@@ -13,7 +13,7 @@ if HAVE_CQL
SUBDIRS += cql SUBDIRS += cql
endif endif
SUBDIRS += config_backend testutils hooks dhcp config stats SUBDIRS += config_backend hooks dhcp config stats
if HAVE_SYSREPO if HAVE_SYSREPO
SUBDIRS += yang SUBDIRS += yang
......
...@@ -30,6 +30,7 @@ libdatabase_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) ...@@ -30,6 +30,7 @@ libdatabase_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
libdatabase_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) libdatabase_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
libdatabase_unittests_LDADD = $(top_builddir)/src/lib/database/libkea-database.la libdatabase_unittests_LDADD = $(top_builddir)/src/lib/database/libkea-database.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la libdatabase_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <config.h> #include <config.h>
#include <database/backend_selector.h> #include <database/backend_selector.h>
#include <testutils/test_to_element.h>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -170,8 +171,6 @@ TEST(BackendSelectorTest, backendTypeToString) { ...@@ -170,8 +171,6 @@ TEST(BackendSelectorTest, backendTypeToString) {
} }
// Tests toElement from backend selectors. // Tests toElement from backend selectors.
// Can't use runToElementTest because it is defined in a library built
// at a later stage.
TEST(BackendSelectorTest, backendToElement) { TEST(BackendSelectorTest, backendToElement) {
// Unspecified. // Unspecified.
boost::scoped_ptr<BackendSelector> sel(new BackendSelector()); boost::scoped_ptr<BackendSelector> sel(new BackendSelector());
...@@ -185,24 +184,17 @@ TEST(BackendSelectorTest, backendToElement) { ...@@ -185,24 +184,17 @@ TEST(BackendSelectorTest, backendToElement) {
EXPECT_NO_THROW(sel.reset(new BackendSelector(BackendSelector::Type::MYSQL))); EXPECT_NO_THROW(sel.reset(new BackendSelector(BackendSelector::Type::MYSQL)));
ElementPtr expected = Element::createMap(); ElementPtr expected = Element::createMap();
expected->set("type", Element::create("mysql")); expected->set("type", Element::create("mysql"));
ConstElementPtr unparsed; test::runToElementTest<BackendSelector>(expected, *sel);
ASSERT_NO_THROW(unparsed = sel->toElement());
ASSERT_TRUE(unparsed);
EXPECT_TRUE(isEquivalent(expected, unparsed));
// Add host. // Add host.
expected->set("host", Element::create("myhost")); expected->set("host", Element::create("myhost"));
EXPECT_NO_THROW(sel.reset(new BackendSelector(expected))); EXPECT_NO_THROW(sel.reset(new BackendSelector(expected)));
ASSERT_NO_THROW(unparsed = sel->toElement()); test::runToElementTest<BackendSelector>(expected, *sel);
ASSERT_TRUE(unparsed);
EXPECT_TRUE(isEquivalent(expected, unparsed));
// Add port. // Add port.
expected->set("port", Element::create(1234L)); expected->set("port", Element::create(1234L));
EXPECT_NO_THROW(sel.reset(new BackendSelector(expected))); EXPECT_NO_THROW(sel.reset(new BackendSelector(expected)));
ASSERT_NO_THROW(unparsed = sel->toElement()); test::runToElementTest<BackendSelector>(expected, *sel);
ASSERT_TRUE(unparsed);
EXPECT_TRUE(isEquivalent(expected, unparsed));
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment