Skip to content

Commit

Permalink
don't try to trap for missing connections, let gtest catch them in pg…
Browse files Browse the repository at this point in the history
…pointcloud tests #744
  • Loading branch information
hobu committed Feb 4, 2015
1 parent ab52c4f commit 1d44750
Showing 1 changed file with 6 additions and 33 deletions.
39 changes: 6 additions & 33 deletions plugins/pgpointcloud/test/PgpointcloudWriterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,8 @@ class PgpointcloudWriterTest : public testing::Test
protected:
virtual void SetUp()
{
try
{
std::string connstr = getMasterDBConn();
m_masterConnection = pg_connect( connstr );
} catch (pdal::pdal_error&)
{
m_masterConnection = 0;
return;
}
std::string connstr = getMasterDBConn();
m_masterConnection = pg_connect( connstr );
m_testConnection = NULL;

// Silence those pesky notices
Expand All @@ -116,24 +109,14 @@ class PgpointcloudWriterTest : public testing::Test
testDbTempname << " TEMPLATE template0";
executeOnMasterDb(createDbSql.str());

try
{
m_testConnection = pg_connect( getTestDBTempConn() );
} catch (pdal::pdal_error&)
{
m_testConnection = 0;
return;
}
m_testConnection = pg_connect( getTestDBTempConn() );

executeOnTestDb("CREATE EXTENSION pointcloud");
}

void executeOnTestDb(const std::string& sql)
{
if (m_testConnection)
pg_execute(m_testConnection, sql);
else
throw std::runtime_error("Not connected to test database for testing!");
pg_execute(m_testConnection, sql);
}

virtual void TearDown()
Expand All @@ -154,22 +137,12 @@ class PgpointcloudWriterTest : public testing::Test

void executeOnMasterDb(const std::string& sql)
{
if (m_masterConnection)
pg_execute(m_masterConnection, sql);
else
throw std::runtime_error("Not connected to database for testing!");
pg_execute(m_masterConnection, sql);
}

void execute(PGconn* connection, const std::string& sql)
{
if (connection)
{
pg_execute(connection, sql);
}
else
{
throw std::runtime_error("Not connected to database for testing");
}
pg_execute(connection, sql);
}

void dropTestDb()
Expand Down

0 comments on commit 1d44750

Please sign in to comment.