Add framework for executing tests against multiple postgresql versions using docker compose.
This commit is contained in:
parent
655c6fceb1
commit
c3bf9e88e4
13 changed files with 457 additions and 0 deletions
63
tests/integration/tst_Smoke.cpp
Normal file
63
tests/integration/tst_Smoke.cpp
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#include "DbTest.h"
|
||||
#include "PgTestEnvironment.h"
|
||||
#include "Pgsql_Result.h"
|
||||
|
||||
using namespace pgtest;
|
||||
|
||||
namespace {
|
||||
|
||||
int scalarInt(Pgsql::Connection &c, const char *sql)
|
||||
{
|
||||
Pgsql::Result r = c.query(sql);
|
||||
EXPECT_EQ(r.rows(), 1);
|
||||
return QString::fromUtf8(r.val(0, 0)).toInt();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class Smoke : public DbTest {};
|
||||
|
||||
TEST_F(Smoke, SelectOne)
|
||||
{
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT 1"), 1);
|
||||
}
|
||||
|
||||
TEST_F(Smoke, RunsOnClonedDatabase)
|
||||
{
|
||||
Pgsql::Result r = conn().query("SELECT current_database()");
|
||||
ASSERT_EQ(r.rows(), 1);
|
||||
EXPECT_EQ(QString::fromUtf8(r.val(0, 0)), dbName());
|
||||
EXPECT_TRUE(dbName().startsWith("t_"));
|
||||
}
|
||||
|
||||
TEST_F(Smoke, ServerVersionAtLeast14)
|
||||
{
|
||||
EXPECT_GE(serverVersionNum(), 140000);
|
||||
}
|
||||
|
||||
TEST_F(Smoke, FixtureSchemaPresent)
|
||||
{
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT count(*) FROM fixture_item"), 2);
|
||||
}
|
||||
|
||||
// The two tests below each modify the database and expect the pristine
|
||||
// fixture state, in whichever order they run.
|
||||
TEST_F(Smoke, IsolationA)
|
||||
{
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT count(*) FROM fixture_item"), 2);
|
||||
conn().query("INSERT INTO fixture_item VALUES (100, 'a')");
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT count(*) FROM fixture_item"), 3);
|
||||
}
|
||||
|
||||
TEST_F(Smoke, IsolationB)
|
||||
{
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT count(*) FROM fixture_item"), 2);
|
||||
conn().query("DELETE FROM fixture_item");
|
||||
EXPECT_EQ(scalarInt(conn(), "SELECT count(*) FROM fixture_item"), 0);
|
||||
}
|
||||
|
||||
TEST_F(Smoke, VersionGate)
|
||||
{
|
||||
REQUIRE_PG_AT_LEAST(15);
|
||||
EXPECT_GE(serverVersionNum(), 150000);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue