Add tests for loading the catalog
This commit is contained in:
parent
591573b6b8
commit
a1ac545086
13 changed files with 203 additions and 32 deletions
36
tests/integration/tst_CatalogLoad.cpp
Normal file
36
tests/integration/tst_CatalogLoad.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "DbTest.h"
|
||||
#include "PgTestEnvironment.h"
|
||||
#include "catalog/PgClassContainer.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "Pgsql_Result.h"
|
||||
|
||||
using namespace pgtest;
|
||||
|
||||
class CatalogLoad : public DbTest {};
|
||||
|
||||
TEST_F(CatalogLoad, SuperuserLoadsCatalog)
|
||||
{
|
||||
PgDatabaseCatalog catalog;
|
||||
catalog.loadAll(conn(), {});
|
||||
|
||||
EXPECT_EQ(catalog.serverVersion(), serverVersionNum());
|
||||
EXPECT_EQ(catalog.getDBName(), dbName());
|
||||
ASSERT_NE(catalog.classes(), nullptr);
|
||||
EXPECT_NE(catalog.classes()->getByObjectNsAndName("public", "fixture_item"), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(CatalogLoad, PlainRoleLoadsCatalog)
|
||||
{
|
||||
auto plain = plainConn();
|
||||
Pgsql::Result r = plain->query("SELECT rolsuper FROM pg_roles WHERE rolname = current_user");
|
||||
ASSERT_EQ(r.rows(), 1);
|
||||
EXPECT_EQ(QString::fromUtf8(r.val(0, 0)), QString("f"));
|
||||
|
||||
PgDatabaseCatalog catalog;
|
||||
catalog.loadAll(*plain, {});
|
||||
|
||||
EXPECT_EQ(catalog.serverVersion(), serverVersionNum());
|
||||
EXPECT_EQ(catalog.getDBName(), dbName());
|
||||
ASSERT_NE(catalog.classes(), nullptr);
|
||||
EXPECT_NE(catalog.classes()->getByObjectNsAndName("public", "fixture_item"), nullptr);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue