Clang: Add project parts table

Change-Id: Id2525b6664c6dc0e9d19f8d58cd26b515ae5640c
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
Marco Bubke
2017-12-27 16:52:04 +01:00
parent 41baafef0c
commit f233f2d26d
3 changed files with 26 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ public:
createLocationsTable(); createLocationsTable();
createSourcesTable(); createSourcesTable();
createDirectoriesTable(); createDirectoriesTable();
createProjectPartsTable();
transaction.commit(); transaction.commit();
} }
@@ -102,6 +103,19 @@ public:
table.initialize(database); table.initialize(database);
} }
void createProjectPartsTable()
{
Sqlite::Table table;
table.setUseIfNotExists(true);
table.setName("projectParts");
table.addColumn("projectPartId", Sqlite::ColumnType::Integer, Sqlite::Contraint::PrimaryKey);
const Sqlite::Column &projectPartNameColumn = table.addColumn("projectPartName", Sqlite::ColumnType::Text);
table.addColumn("compilerArguments", Sqlite::ColumnType::Text);
table.addIndex({projectPartNameColumn});
table.initialize(database);
}
public: public:
DatabaseType &database; DatabaseType &database;
}; };

View File

@@ -79,9 +79,19 @@ TEST_F(RefactoringDatabaseInitializer, AddDirectoriesTable)
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS directories(directoryId INTEGER PRIMARY KEY, directoryPath TEXT)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS directories(directoryId INTEGER PRIMARY KEY, directoryPath TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_directories_directoryPath ON directories(directoryPath)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_directories_directoryPath ON directories(directoryPath)")));
initializer.createDirectoriesTable(); initializer.createDirectoriesTable();
} }
TEST_F(RefactoringDatabaseInitializer, AddProjectPartsTable)
{
InSequence s;
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS projectParts(projectPartId INTEGER PRIMARY KEY, projectPartName TEXT, compilerArguments TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_projectParts_projectPartName ON projectParts(projectPartName)")));
initializer.createProjectPartsTable();
}
TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor) TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor)
{ {
@@ -97,6 +107,8 @@ TEST_F(RefactoringDatabaseInitializer, CreateInTheContructor)
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_sources_sourceName ON sources(sourceName)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_sources_sourceName ON sources(sourceName)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS directories(directoryId INTEGER PRIMARY KEY, directoryPath TEXT)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS directories(directoryId INTEGER PRIMARY KEY, directoryPath TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_directories_directoryPath ON directories(directoryPath)"))); EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_directories_directoryPath ON directories(directoryPath)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE TABLE IF NOT EXISTS projectParts(projectPartId INTEGER PRIMARY KEY, projectPartName TEXT, compilerArguments TEXT)")));
EXPECT_CALL(mockDatabase, execute(Eq("CREATE INDEX IF NOT EXISTS index_projectParts_projectPartName ON projectParts(projectPartName)")));
EXPECT_CALL(mockDatabase, execute(Eq("COMMIT"))); EXPECT_CALL(mockDatabase, execute(Eq("COMMIT")));
EXPECT_CALL(mockMutex, unlock()); EXPECT_CALL(mockMutex, unlock());

View File

@@ -62,7 +62,6 @@ TEST_F(StorageSqliteStatementFactory, AddNewSymbolsTable)
factory.createNewSymbolsTable(); factory.createNewSymbolsTable();
} }
TEST_F(StorageSqliteStatementFactory, AddNewLocationsTable) TEST_F(StorageSqliteStatementFactory, AddNewLocationsTable)
{ {
InSequence s; InSequence s;