diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 15:46:08 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-17 15:46:08 +0100 |
commit | cf83772205629933e82363144fcc61fe306c323d (patch) | |
tree | 8c2413ac9ce3341e4d3bd15c14ea74c4a1aac29d | |
parent | Tidy up execute method (diff) | |
download | libdbpp-cf83772205629933e82363144fcc61fe306c323d.tar.bz2 libdbpp-cf83772205629933e82363144fcc61fe306c323d.tar.xz libdbpp-cf83772205629933e82363144fcc61fe306c323d.zip |
Test savepoints
-rw-r--r-- | libdbpp/unittests/testConnection.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libdbpp/unittests/testConnection.cpp b/libdbpp/unittests/testConnection.cpp index 883c09a..bcfadeb 100644 --- a/libdbpp/unittests/testConnection.cpp +++ b/libdbpp/unittests/testConnection.cpp @@ -17,9 +17,6 @@ class MockDb : public DB::Connection { int commitTx() const { return 0; } int rollbackTx() const { return 0; } bool inTx() const { return false; } - void savepoint(const std::string &) const {} - void rollbackToSavepoint(const std::string &) const {} - void releaseSavepoint(const std::string &) const {} void ping() const {} DB::BulkDeleteStyle bulkDeleteStyle() const { return DB::BulkDeleteUsingUsing; } DB::BulkUpdateStyle bulkUpdateStyle() const { return DB::BulkUpdateUsingJoin; } @@ -77,3 +74,21 @@ BOOST_AUTO_TEST_CASE( parse ) delete mock; } +BOOST_AUTO_TEST_CASE( savepoints ) +{ + auto mock = DB::ConnectionFactory::createNew("MockDb", "doesn't matter"); + MockDb * mockdb = dynamic_cast<MockDb *>(mock); + BOOST_REQUIRE(mockdb); + mock->savepoint("sp"); + BOOST_REQUIRE_EQUAL("SAVEPOINT sp", *mockdb->executed.rbegin()); + mock->releaseSavepoint("sp"); + BOOST_REQUIRE_EQUAL("RELEASE SAVEPOINT sp", *mockdb->executed.rbegin()); + mock->savepoint("sp1"); + BOOST_REQUIRE_EQUAL("SAVEPOINT sp1", *mockdb->executed.rbegin()); + mock->savepoint("sp2"); + BOOST_REQUIRE_EQUAL("SAVEPOINT sp2", *mockdb->executed.rbegin()); + mock->rollbackToSavepoint("sp1"); + BOOST_REQUIRE_EQUAL("ROLLBACK TO SAVEPOINT sp1", *mockdb->executed.rbegin()); + delete mock; +} + |