Commit 4764d6f4 authored by Steven Murray's avatar Steven Murray
Browse files

Added LoginTest unit-tests parseStream_invalid_in_memory,...

Added LoginTest unit-tests parseStream_invalid_in_memory, parseStream_invalid_oracle and parseStream_invalid_sqlite
parent f8ff9536
......@@ -195,6 +195,11 @@ Login Login::parseOracle(const std::string &connectionDetails) {
//------------------------------------------------------------------------------
Login Login::parseSqlite(const std::string &connectionDetails) {
const std::string &filename = connectionDetails;
if(filename.empty()) {
throw exception::Exception(std::string("Invalid connection string: Correct format is ") + s_fileFormat);
}
return Login(DBTYPE_SQLITE, "", "", filename, "", 0);
}
......
......@@ -77,6 +77,24 @@ TEST_F(cta_rdbms_LoginTest, parseStream_in_memory) {
ASSERT_TRUE(login.database.empty());
}
TEST_F(cta_rdbms_LoginTest, parseStream_invalid_in_memory) {
using namespace cta;
using namespace cta::rdbms;
std::stringstream inputStream;
inputStream << "# A comment" << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << "# Another comment" << std::endl;
inputStream << "in_memory:invalid";
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
ASSERT_THROW(Login::parseStream(inputStream), exception::Exception);
}
TEST_F(cta_rdbms_LoginTest, parseStream_oracle) {
using namespace cta::rdbms;
......@@ -98,6 +116,24 @@ TEST_F(cta_rdbms_LoginTest, parseStream_oracle) {
ASSERT_EQ(std::string("database"), login.database);
}
TEST_F(cta_rdbms_LoginTest, parseStream_invalid_oracle) {
using namespace cta;
using namespace cta::rdbms;
std::stringstream inputStream;
inputStream << "# A comment" << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << "# Another comment" << std::endl;
inputStream << "oracle:invalid" << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
ASSERT_THROW(Login::parseStream(inputStream), exception::Exception);
}
TEST_F(cta_rdbms_LoginTest, parseStream_oracle_password_with_a_hash) {
using namespace cta::rdbms;
......@@ -140,6 +176,24 @@ TEST_F(cta_rdbms_LoginTest, parseStream_sqlite) {
ASSERT_EQ(std::string("filename"), login.database);
}
TEST_F(cta_rdbms_LoginTest, parseStream_invalid_sqlite) {
using namespace cta;
using namespace cta::rdbms;
std::stringstream inputStream;
inputStream << "# A comment" << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << "# Another comment" << std::endl;
inputStream << "sqlite:" << std::endl;
inputStream << std::endl;
inputStream << std::endl;
inputStream << std::endl;
ASSERT_THROW(Login::parseStream(inputStream), exception::Exception);
}
TEST_F(cta_rdbms_LoginTest, parseStream_invalid) {
using namespace cta;
using namespace cta::rdbms;
......
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