Commit 42c52619 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[2541] Add two more tests to database_unittest

parent fe8a9e7c
......@@ -4103,6 +4103,7 @@ TYPED_TEST(DatabaseClientTest, createZone) {
const DataSourceClient::FindResult
zone(this->client_->findZone(new_name));
ASSERT_EQ(result::NOTFOUND, zone.code);
// The mock implementation does not do createZone,
// in which case it should throw NotImplemented (from
// the base class)
......@@ -4120,4 +4121,34 @@ TYPED_TEST(DatabaseClientTest, createZone) {
}
}
TYPED_TEST(DatabaseClientTest, createZoneRollbackOnLocked) {
// skip test for mock
if (this->is_mock_) {
return;
}
const Name new_name("example.com");
isc::datasrc::ZoneUpdaterPtr updater =
this->client_->getUpdater(isc::dns::Name(this->zname_), true);
ASSERT_THROW(this->client_->createZone(new_name), DataSourceError);
// createZone started a transaction as well, but since it failed,
// it should have been rolled back. Roll back the other one as
// well, and the next attempt should succeed
updater.reset();
ASSERT_TRUE(this->client_->createZone(new_name));
}
TYPED_TEST(DatabaseClientTest, createZoneRollbackOnExists) {
// skip test for mock
if (this->is_mock_) {
return;
}
const Name new_name("example.com");
ASSERT_FALSE(this->client_->createZone(this->zname_));
// createZone started a transaction, but since it failed,
// it should have been rolled back, and the next attempt should succeed
ASSERT_TRUE(this->client_->createZone(new_name));
}
}
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