2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 22:15:23 +00:00

[2378] Test throwing when missing zone

This commit is contained in:
Michal 'vorner' Vaner
2012-11-27 14:03:44 +01:00
parent c842187ad9
commit c9825a5714

View File

@@ -41,7 +41,8 @@ namespace {
class MockClient : public DataSourceClient { class MockClient : public DataSourceClient {
public: public:
MockClient() : MockClient() :
commit_called_(false) commit_called_(false),
missing_zone_(false)
{} {}
virtual FindResult findZone(const Name&) const { virtual FindResult findZone(const Name&) const {
isc_throw(isc::NotImplemented, "Method not used in tests"); isc_throw(isc::NotImplemented, "Method not used in tests");
@@ -64,6 +65,8 @@ public:
// we get them as references. // we get them as references.
vector<string> rrsets_; vector<string> rrsets_;
bool commit_called_; bool commit_called_;
// If set to true, getUpdater returns NULL
bool missing_zone_;
}; };
// The updater isn't really correct according to the API. For example, // The updater isn't really correct according to the API. For example,
@@ -97,6 +100,9 @@ private:
ZoneUpdaterPtr ZoneUpdaterPtr
MockClient::getUpdater(const Name& name, bool replace, bool journaling) const { MockClient::getUpdater(const Name& name, bool replace, bool journaling) const {
if (missing_zone_) {
return (ZoneUpdaterPtr());
}
EXPECT_TRUE(replace); EXPECT_TRUE(replace);
EXPECT_FALSE(journaling); EXPECT_FALSE(journaling);
provided_updaters_.push_back(name); provided_updaters_.push_back(name);
@@ -222,4 +228,18 @@ TEST_F(ZoneLoaderTest, copySigned) {
destination_client_.rrsets_[1]); destination_client_.rrsets_[1]);
} }
// If the destination zone does not exist, it throws
TEST_F(ZoneLoaderTest, copyMissingDestination) {
destination_client_.missing_zone_ = true;
prepareSource(Name::ROOT_NAME(), "root.zone");
EXPECT_THROW(ZoneLoader(destination_client_, Name::ROOT_NAME(),
source_client_), DataSourceError);
}
// If the source zone does not exist, it throws
TEST_F(ZoneLoaderTest, copyMissingSource) {
EXPECT_THROW(ZoneLoader(destination_client_, Name::ROOT_NAME(),
source_client_), DataSourceError);
}
} }