mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 05:27:55 +00:00
[709-cb_cmds-add-support-for-commands-to-manage-the-servers] Added delServerTag
This commit is contained in:
parent
f693084db5
commit
3d618610fc
@ -67,7 +67,7 @@ protected:
|
||||
/// @brief Database identifier of the configuration element.
|
||||
///
|
||||
/// The default value of 0 indicates that the identifier is
|
||||
/// not set.
|
||||
/// not set.
|
||||
uint64_t id_;
|
||||
|
||||
/// @brief Holds timestamp value.
|
||||
|
@ -23,6 +23,17 @@ StampedElement::hasServerTag(const ServerTag& server_tag) const {
|
||||
return (false);
|
||||
}
|
||||
|
||||
void
|
||||
StampedElement::delServerTag(const std::string& server_tag) {
|
||||
for (auto it = server_tags_.begin(); it < server_tags_.end(); ++it) {
|
||||
if (it->get() == server_tag) {
|
||||
server_tags_.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
isc_throw(NotFound, "can't find server tag '" << server_tag << "' to delete");
|
||||
}
|
||||
|
||||
bool
|
||||
StampedElement::hasAllServerTag() const {
|
||||
return (hasServerTag(ServerTag(ServerTag::ALL)));
|
||||
|
@ -47,6 +47,14 @@ public:
|
||||
server_tags_.push_back(ServerTag(server_tag));
|
||||
}
|
||||
|
||||
/// @brief Deletes server tag.
|
||||
///
|
||||
/// Remove the first occurrence of the given server tag.
|
||||
///
|
||||
/// @param server_tag server tag to delete.
|
||||
/// @throw NotFound if the server tag cannot be found.
|
||||
void delServerTag(const std::string& server_tag);
|
||||
|
||||
/// @brief Returns server tags.
|
||||
///
|
||||
/// @return Server tag as string.
|
||||
|
@ -71,7 +71,7 @@ TEST(StampedElementTest, update) {
|
||||
}
|
||||
|
||||
// Tests that one or more server tag can be specified.
|
||||
TEST(StampedElementTest, setServerTags) {
|
||||
TEST(StampedElementTest, setServerTag) {
|
||||
StampedElement element;
|
||||
element.setServerTag("foo");
|
||||
EXPECT_EQ(1, element.getServerTags().size());
|
||||
@ -91,6 +91,26 @@ TEST(StampedElementTest, setServerTags) {
|
||||
EXPECT_TRUE(element.hasAllServerTag());
|
||||
}
|
||||
|
||||
// Tests that a server tag can be deleted.
|
||||
TEST(StampedElementTest, delServerTag) {
|
||||
StampedElement element;
|
||||
EXPECT_THROW(element.delServerTag("foo"), isc::NotFound);
|
||||
element.setServerTag("foo");
|
||||
element.setServerTag("foo");
|
||||
ASSERT_EQ(2, element.getServerTags().size());
|
||||
EXPECT_EQ("foo", element.getServerTags()[0].get());
|
||||
EXPECT_EQ("foo", element.getServerTags()[1].get());
|
||||
|
||||
EXPECT_NO_THROW(element.delServerTag("foo"));
|
||||
ASSERT_EQ(1, element.getServerTags().size());
|
||||
EXPECT_EQ("foo", element.getServerTags()[0].get());
|
||||
|
||||
EXPECT_NO_THROW(element.delServerTag("foo"));
|
||||
EXPECT_EQ(0, element.getServerTags().size());
|
||||
EXPECT_THROW(element.delServerTag("foo"), isc::NotFound);
|
||||
}
|
||||
|
||||
|
||||
// Test that metadata can be created from the StampedElement.
|
||||
TEST(StampedElementTest, getMetadata) {
|
||||
StampedElement element;
|
||||
|
Loading…
x
Reference in New Issue
Block a user