From cabf3da54251ce394d286b612a074ad893a61931 Mon Sep 17 00:00:00 2001 From: Slawek Figiel Date: Mon, 17 Apr 2023 10:53:06 +0200 Subject: [PATCH] [#2815] Add more unit tests --- src/lib/dhcpsrv/tests/host_mgr_unittest.cc | 23 ++++++++++++++++++ .../tests/mysql_host_data_source_unittest.cc | 24 +++++++++++++++++++ .../tests/pgsql_host_data_source_unittest.cc | 24 +++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc index bec8e0951d..a57e357f0e 100644 --- a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc @@ -153,6 +153,29 @@ TEST_F(HostMgrTest, get6ByPrefix) { testGet6ByPrefix(*getCfgHosts(), *getCfgHosts()); } +// This test verifies that the reservations can be added using HostMgr. +TEST_F(HostMgrTest, add) { + testAdd(*getCfgHosts(), *getCfgHosts()); +} + +// This test verifies that the reservations can be deleted by subnet ID and +// address using HostMgr.. +TEST_F(HostMgrTest, del) { + testDeleteByIDAndAddress(*getCfgHosts(), *getCfgHosts()); +} + +// This test verifies that the IPv4 reservations can be deleted by subnet ID +// and identifier using HostMgr. +TEST_F(HostMgrTest, del4) { + testDelete4ByIDAndIdentifier(*getCfgHosts(), *getCfgHosts()); +} + +// This test verifies that the IPv6 reservations can be deleted by subnet ID +// and identifier using HostMgr.. +TEST_F(HostMgrTest, del6) { + testDelete6ByIDAndIdentifier(*getCfgHosts(), *getCfgHosts()); +} + // This test verifies that without a host data source an exception is thrown. TEST_F(HostMgrTest, noDataSource) { // Remove all configuration. diff --git a/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc index ab4924a554..eb3b9d975c 100644 --- a/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/mysql_host_data_source_unittest.cc @@ -1647,6 +1647,30 @@ TEST_F(MySQLHostMgrTest, get6ByPrefix) { testGet6ByPrefix(*getCfgHosts(), HostMgr::instance()); } +// This test verifies that the reservations can be added to a configuration +// file and a database. +TEST_F(MySQLHostMgrTest, add) { + testAdd(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the reservations can be deleted from a configuration +// file and a database by subnet ID and address. +TEST_F(MySQLHostMgrTest, del) { + testDeleteByIDAndAddress(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the IPv4 reservations can be deleted from a +// configuration file and a database by subnet ID and identifier. +TEST_F(MySQLHostMgrTest, del4) { + testDelete4ByIDAndIdentifier(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the IPv6 reservations can be deleted from a +// configuration file and a database by subnet ID and identifier. +TEST_F(MySQLHostMgrTest, del6) { + testDelete6ByIDAndIdentifier(*getCfgHosts(), HostMgr::instance()); +} + // This test verifies that it is possible to control whether the reserved // IP addresses are unique or non unique via the HostMgr. TEST_F(MySQLHostMgrTest, setIPReservationsUnique) { diff --git a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc index 8f55a4459f..681a9c648f 100644 --- a/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc +++ b/src/lib/dhcpsrv/tests/pgsql_host_data_source_unittest.cc @@ -1615,6 +1615,30 @@ TEST_F(PgSQLHostMgrTest, get6ByPrefix) { testGet6ByPrefix(*getCfgHosts(), HostMgr::instance()); } +// This test verifies that the reservations can be added to a configuration +// file and a database. +TEST_F(PgSQLHostMgrTest, add) { + testAdd(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the reservations can be deleted from a configuration +// file and a database by subnet ID and address. +TEST_F(PgSQLHostMgrTest, del) { + testDeleteByIDAndAddress(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the IPv4 reservations can be deleted from a +// configuration file and a database by subnet ID and identifier. +TEST_F(PgSQLHostMgrTest, del4) { + testDelete4ByIDAndIdentifier(*getCfgHosts(), HostMgr::instance()); +} + +// This test verifies that the IPv6 reservations can be deleted from a +// configuration file and a database by subnet ID and identifier. +TEST_F(PgSQLHostMgrTest, del6) { + testDelete6ByIDAndIdentifier(*getCfgHosts(), HostMgr::instance()); +} + // This test verifies that it is possible to control whether the reserved // IP addresses are unique or non unique via the HostMgr. TEST_F(PgSQLHostMgrTest, setIPReservationsUnique) { -- 2.47.2