summaryrefslogtreecommitdiff
path: root/libpqpp/unittests
diff options
context:
space:
mode:
authorDan Goodliffe <daniel.goodliffe@pressassociation.com>2016-04-21 10:59:36 +0100
committerDan Goodliffe <daniel.goodliffe@pressassociation.com>2016-04-21 10:59:36 +0100
commitafcde49538230d4f8648e227f8a861b5a1b9a83c (patch)
tree4f6ea35c9c5025a2db6647fa49272e5a3b4e57b4 /libpqpp/unittests
parentActually, don't prepare statement upfront during construction as it might not... (diff)
downloadlibdbpp-postgresql-afcde49538230d4f8648e227f8a861b5a1b9a83c.tar.bz2
libdbpp-postgresql-afcde49538230d4f8648e227f8a861b5a1b9a83c.tar.xz
libdbpp-postgresql-afcde49538230d4f8648e227f8a861b5a1b9a83c.zip
Don't attempt to close cursors when in failed transaction (it's failed and result in sigabrt)
Diffstat (limited to 'libpqpp/unittests')
-rw-r--r--libpqpp/unittests/testpq.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index 1905192..64d60d9 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -11,6 +11,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <pq-error.h>
#include <pq-connection.h>
+#include <selectcommandUtil.impl.h>
class StandardMockDatabase : public PQ::Mock {
public:
@@ -286,6 +287,37 @@ BOOST_AUTO_TEST_CASE( statementReuse )
delete ro;
}
+BOOST_AUTO_TEST_CASE( closeOnError )
+{
+ auto ro = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("pqmock"));
+ BOOST_REQUIRE_THROW({
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->execute("nonsense");
+ });
+ }, DB::Error);
+ BOOST_REQUIRE_THROW({
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->execute("nonsense");
+ });
+ });
+ }, DB::Error);
+ ro->beginTx();
+ BOOST_REQUIRE_THROW({
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->execute("nonsense");
+ });
+ }, DB::Error);
+ BOOST_REQUIRE_THROW({
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->select("SELECT * FROM test")->forEachRow<>([&ro](){
+ ro->execute("nonsense");
+ });
+ });
+ }, DB::Error);
+ ro->commitTx();
+}
+
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE( connfail )