Commit e18062ea authored by Steven Murray's avatar Steven Murray
Browse files

Added existence tests to MockLogicalLibraryTable and MockTapePoolTable

parent c58e0400
......@@ -30,6 +30,20 @@ void cta::MockLogicalLibraryTable::checkLogicalLibraryDoesNotAlreadyExist(
throw(Exception(message.str()));
}
}
//------------------------------------------------------------------------------
// checkLogicalLibraryExists
//------------------------------------------------------------------------------
void cta::MockLogicalLibraryTable::checkLogicalLibraryExists(
const std::string &name) const {
std::map<std::string, LogicalLibrary>::const_iterator itor =
m_libraries.find(name);
if(itor == m_libraries.end()) {
std::ostringstream message;
message << "Logical library " << name << " does not exist";
throw(Exception(message.str()));
}
}
//------------------------------------------------------------------------------
// deleteLogicalLibrary
......
......@@ -35,6 +35,13 @@ public:
*/
void checkLogicalLibraryDoesNotAlreadyExist(const std::string &name) const;
/**
* Throws an exception if the specified logical library does not exists.
*
* @param name The name of the logical library.
*/
void checkLogicalLibraryExists(const std::string &name) const;
/**
* Deletes the logical library with the specified name.
*
......
......@@ -27,6 +27,9 @@ TEST_F(cta_client_MockLogicalLibraryTableTest, createLogicalLibrary_new) {
}
const std::string libraryName = "TestLogicalLibrary";
ASSERT_THROW(db.checkLogicalLibraryExists(libraryName), std::exception);
const std::string libraryComment = "Comment";
ASSERT_NO_THROW(db.createLogicalLibrary(requester, libraryName,
libraryComment));
......@@ -41,6 +44,8 @@ TEST_F(cta_client_MockLogicalLibraryTableTest, createLogicalLibrary_new) {
ASSERT_EQ(libraryName, logicalLibrary.getName());
ASSERT_EQ(libraryComment, logicalLibrary.getComment());
}
ASSERT_NO_THROW(db.checkLogicalLibraryExists(libraryName));
}
TEST_F(cta_client_MockLogicalLibraryTableTest,
......
......@@ -31,6 +31,20 @@ void cta::MockTapePoolTable::checkTapePoolDoesNotAlreadyExist(
}
}
//------------------------------------------------------------------------------
// checkTapePoolExists
//------------------------------------------------------------------------------
void cta::MockTapePoolTable::checkTapePoolExists(
const std::string &name) const {
std::map<std::string, TapePool>::const_iterator itor =
m_tapePools.find(name);
if(itor == m_tapePools.end()) {
std::ostringstream message;
message << "The " << name << " tape pool does not exist";
throw Exception(message.str());
}
}
//------------------------------------------------------------------------------
// deleteTapePool
//------------------------------------------------------------------------------
......
......@@ -36,12 +36,19 @@ public:
const std::string &comment);
/**
* Throws an exception if the specified tape pool already exixts.
* Throws an exception if the specified tape pool already exists.
*
* @param name The name of the tape pool.
*/
void checkTapePoolDoesNotAlreadyExist(const std::string &name) const;
/**
* Throws an exception if the specified tape pool does not exist.
*
* @param name The name of the tape pool.
*/
void checkTapePoolExists(const std::string &name) const;
/**
* Delete the tape pool with the specifed name.
*
......
......@@ -27,6 +27,9 @@ TEST_F(cta_client_MockTapePoolTableTest, createTapePool_new) {
}
const std::string tapePoolName = "TestTapePool";
ASSERT_THROW(db.checkTapePoolExists(tapePoolName), std::exception);
const uint16_t nbDrives = 1;
const uint16_t nbPartialTapes = 1;
const std::string comment = "Comment";
......@@ -43,6 +46,8 @@ TEST_F(cta_client_MockTapePoolTableTest, createTapePool_new) {
ASSERT_EQ(tapePoolName, tapePool.getName());
ASSERT_EQ(comment, tapePool.getComment());
}
ASSERT_NO_THROW(db.checkTapePoolExists(tapePoolName));
}
TEST_F(cta_client_MockTapePoolTableTest, createTapePool_already_existing) {
......
Supports Markdown
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