summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-06-13 13:01:28 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-06-13 13:01:28 +0100
commitbaa9b0d87d3a8ff4d9d7f800b36d6519011c92be (patch)
treef9ede39290d96dd3d57c4b6ed2063671cf9ee89a /test
parentSupport creating a PostgreSQL mock DB and filling it with a schema script (diff)
downloadmygrate-baa9b0d87d3a8ff4d9d7f800b36d6519011c92be.tar.bz2
mygrate-baa9b0d87d3a8ff4d9d7f800b36d6519011c92be.tar.xz
mygrate-baa9b0d87d3a8ff4d9d7f800b36d6519011c92be.zip
Run non-readonly PQ tests in tmp db
Diffstat (limited to 'test')
-rw-r--r--test/test-postgresql.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/test/test-postgresql.cpp b/test/test-postgresql.cpp
index faafcc0..8adb920 100644
--- a/test/test-postgresql.cpp
+++ b/test/test-postgresql.cpp
@@ -30,14 +30,6 @@ BOOST_AUTO_TEST_CASE(simple)
BOOST_CHECK_THROW(c.query("SET application_name = "), MyGrate::Output::Pq::PqErr);
// BOOST_CHECK_THROW(c.query("SET application_name = $1", {}), std::logic_error);
BOOST_CHECK_NO_THROW(c.query("SET application_name = 'something'", {}));
- c.query("DROP TABLE IF EXISTS test");
- c.query("CREATE TABLE test(c text)");
- BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {1}));
- BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {"string_view"}));
- BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {nullptr}));
- BOOST_CHECK_NO_THROW(c.query("INSERT INTO test VALUES($1)", {1.2}));
- BOOST_CHECK_THROW(c.query("INSERT INTO test VALUES($1)", {MyGrate::Time {}}), std::logic_error);
- c.query("DROP TABLE test");
}
using SomeUpdate = MyGrate::DbStmt<"UPDATE foo SET blah = $2 WHERE bar = $1">;
@@ -81,6 +73,15 @@ BOOST_AUTO_TEST_CASE(mock)
auto mdb = db.mock();
auto rs = MyGrate::DbStmt<"SELECT CURRENT_DATABASE()">::execute(&mdb);
BOOST_CHECK_EQUAL(rs->at(0, 0).get<std::string_view>().substr(0, 13), "mygrate_test_");
+
+ mdb.query("CREATE TABLE test(c text)");
+ BOOST_CHECK_NO_THROW(mdb.query("INSERT INTO test VALUES($1)", {1}));
+ BOOST_CHECK_NO_THROW(mdb.query("INSERT INTO test VALUES($1)", {"string_view"}));
+ BOOST_CHECK_NO_THROW(mdb.query("INSERT INTO test VALUES($1)", {nullptr}));
+ BOOST_CHECK_NO_THROW(mdb.query("INSERT INTO test VALUES($1)", {1.2}));
+ BOOST_CHECK_THROW(mdb.query("INSERT INTO test VALUES($1)", {MyGrate::Time {}}), std::logic_error);
+ auto rscount = MyGrate::DbStmt<"SELECT COUNT(*) FROM test">::execute(&mdb);
+ BOOST_CHECK_EQUAL(rscount->at(0, 0).operator unsigned int(), 4);
}
BOOST_AUTO_TEST_CASE(mock_schema)