mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 22:45:18 +00:00
[#103,!277] Fixed failing unit test.
This commit is contained in:
@@ -71,7 +71,8 @@ public:
|
|||||||
|
|
||||||
/// @brief Constructor.
|
/// @brief Constructor.
|
||||||
TestCBControlDHCPv4()
|
TestCBControlDHCPv4()
|
||||||
: CBControlDHCPv4(), db_config_fetch_calls_(0), enable_throw_(false) {
|
: CBControlDHCPv4(), db_config_fetch_calls_(0),
|
||||||
|
enable_check_fetch_updates_only_(false), enable_throw_(false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Stub implementation of the "fetch" function.
|
/// @brief Stub implementation of the "fetch" function.
|
||||||
@@ -88,9 +89,17 @@ public:
|
|||||||
/// @throw Unexpected when configured to do so.
|
/// @throw Unexpected when configured to do so.
|
||||||
virtual void databaseConfigFetch(const process::ConfigPtr&,
|
virtual void databaseConfigFetch(const process::ConfigPtr&,
|
||||||
const bool fetch_updates_only) {
|
const bool fetch_updates_only) {
|
||||||
if ((db_config_fetch_calls_++ > 0) && !fetch_updates_only) {
|
++db_config_fetch_calls_;
|
||||||
|
|
||||||
|
if (enable_check_fetch_updates_only_) {
|
||||||
|
if ((db_config_fetch_calls_ <= 1) && fetch_updates_only) {
|
||||||
ADD_FAILURE() << "databaseConfigFetch was called with the value "
|
ADD_FAILURE() << "databaseConfigFetch was called with the value "
|
||||||
"of fetch_updates_only=false";
|
"of fetch_updates_only=true upon the server configuration";
|
||||||
|
|
||||||
|
} else if ((db_config_fetch_calls_ > 1) && !fetch_updates_only) {
|
||||||
|
ADD_FAILURE() << "databaseConfigFetch was called with the value "
|
||||||
|
"of fetch_updates_only=false during fetching the updates";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_throw_) {
|
if (enable_throw_) {
|
||||||
@@ -103,6 +112,11 @@ public:
|
|||||||
return (db_config_fetch_calls_);
|
return (db_config_fetch_calls_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Enables checking of the @c fetch_updates_only value.
|
||||||
|
void enableCheckFetchUpdatesOnly() {
|
||||||
|
enable_check_fetch_updates_only_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Enables the object to throw from @c databaseConfigFetch.
|
/// @brief Enables the object to throw from @c databaseConfigFetch.
|
||||||
void enableThrow() {
|
void enableThrow() {
|
||||||
enable_throw_ = true;
|
enable_throw_ = true;
|
||||||
@@ -113,6 +127,10 @@ private:
|
|||||||
/// @brief Counter holding number of invocations of the @c databaseConfigFetch.
|
/// @brief Counter holding number of invocations of the @c databaseConfigFetch.
|
||||||
size_t db_config_fetch_calls_;
|
size_t db_config_fetch_calls_;
|
||||||
|
|
||||||
|
/// @brief Boolean flag indicated if the value of the @c fetch_updates_only
|
||||||
|
/// should be verified.
|
||||||
|
bool enable_check_fetch_updates_only_;
|
||||||
|
|
||||||
/// @brief Boolean flag indicating if the @c databaseConfigFetch should
|
/// @brief Boolean flag indicating if the @c databaseConfigFetch should
|
||||||
/// throw.
|
/// throw.
|
||||||
bool enable_throw_;
|
bool enable_throw_;
|
||||||
@@ -227,6 +245,10 @@ public:
|
|||||||
// Get the CBControlDHCPv4 object belonging to this server.
|
// Get the CBControlDHCPv4 object belonging to this server.
|
||||||
auto cb_control = boost::dynamic_pointer_cast<TestCBControlDHCPv4>(srv->getCBControl());
|
auto cb_control = boost::dynamic_pointer_cast<TestCBControlDHCPv4>(srv->getCBControl());
|
||||||
|
|
||||||
|
// Verify that the boolean parameter passed to the databaseConfigFetch
|
||||||
|
// has an expected value.
|
||||||
|
cb_control->enableCheckFetchUpdatesOnly();
|
||||||
|
|
||||||
// Instruct our stub implementation of the CBControlDHCPv4 to throw as a
|
// Instruct our stub implementation of the CBControlDHCPv4 to throw as a
|
||||||
// result of fetch if desired.
|
// result of fetch if desired.
|
||||||
if (throw_during_fetch) {
|
if (throw_during_fetch) {
|
||||||
|
Reference in New Issue
Block a user