The table inheritance works mostly
This commit is contained in:
parent
ccd88d0578
commit
2ff9577d41
22 changed files with 473 additions and 145 deletions
64
tests/pglabtests/TableTreeBuilderTests.cpp
Normal file
64
tests/pglabtests/TableTreeBuilderTests.cpp
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "PrintTo_Qt.h"
|
||||
|
||||
#include "catalog/PgClass.h"
|
||||
#include "catalog/PgDatabaseCatalog.h"
|
||||
#include "ui/catalog/tables/TableTreeBuilder.h"
|
||||
#include "ui/catalog/tables/TableNode.h"
|
||||
#include "catalog/PgInheritsContainer.h"
|
||||
|
||||
TEST(TableTreeBuilder, EmptySourceEmptyResult)
|
||||
{
|
||||
std::map<Oid, PgClass> source;
|
||||
PgDatabaseCatalog catalog;
|
||||
PgInheritsContainer inherited(catalog);
|
||||
TableTreeBuilder builder(source, inherited);
|
||||
auto [result, index] = builder.Build();
|
||||
|
||||
EXPECT_EQ(result->children.size(), 0);
|
||||
}
|
||||
|
||||
|
||||
TEST(TableTreeBuilder, TopLevelOnly)
|
||||
{
|
||||
std::map<Oid, PgClass> source;
|
||||
|
||||
PgDatabaseCatalog catalog;
|
||||
PgClass cls1(catalog, 1000, "a", 11);
|
||||
source.emplace(1000, cls1);
|
||||
PgInheritsContainer inherited(catalog);
|
||||
TableTreeBuilder builder(source, inherited);
|
||||
auto [result, index] = builder.Build();
|
||||
|
||||
EXPECT_EQ(result->children.size(), 1);
|
||||
}
|
||||
|
||||
class FakeIFindParents : public IFindParents
|
||||
{
|
||||
public:
|
||||
std::vector<Oid> getParentsOf(Oid oid) const override
|
||||
{
|
||||
if (oid == 1001)
|
||||
return { 1002 };
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
TEST(TableTreeBuilder, WithChild)
|
||||
{
|
||||
std::map<Oid, PgClass> source;
|
||||
|
||||
FakeIFindParents findParents;
|
||||
PgDatabaseCatalog catalog;
|
||||
PgClass cls1(catalog, 1001, "a", 11);
|
||||
source.emplace(1001, cls1);
|
||||
PgClass cls2(catalog, 1002, "b", 11);
|
||||
source.emplace(1002, cls2);
|
||||
PgInheritsContainer inherited(catalog);
|
||||
TableTreeBuilder builder(source, findParents);
|
||||
auto [result, index] = builder.Build();
|
||||
|
||||
EXPECT_EQ(result->children.size(), 1);
|
||||
EXPECT_EQ(result->children[0]->children.size(), 1);
|
||||
EXPECT_TRUE(result->children[0]->children[0]->parent.lock() == result->children[0]);
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ QT += core widgets
|
|||
HEADERS +=
|
||||
|
||||
SOURCES += main.cpp \
|
||||
TableTreeBuilderTests.cpp \
|
||||
tst_ConvertLangToSqlString.cpp \
|
||||
tst_ConvertToMultiLineCString.cpp \
|
||||
tst_ExplainJsonParser.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue