-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flash-372] add tests for new schema syncer (#158)
- Loading branch information
1 parent
2f8ee1b
commit 8c524a2
Showing
33 changed files
with
248 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <Debug/MockTiDB.h> | ||
#include <Storages/Transaction/SchemaGetter.h> | ||
|
||
namespace DB | ||
{ | ||
|
||
struct MockSchemaGetter | ||
{ | ||
|
||
TiDB::DBInfoPtr getDatabase(DatabaseID db_id) { return MockTiDB::instance().getDBInfoByID(db_id); } | ||
|
||
Int64 getVersion() { return MockTiDB::instance().getVersion(); } | ||
|
||
SchemaDiff getSchemaDiff(Int64 version) { return MockTiDB::instance().getSchemaDiff(version); } | ||
|
||
TiDB::TableInfoPtr getTableInfo(DatabaseID, TableID table_id) { return MockTiDB::instance().getTableInfoByID(table_id); } | ||
|
||
std::vector<TiDB::DBInfoPtr> listDBs() | ||
{ | ||
std::vector<TiDB::DBInfoPtr> res; | ||
const auto & databases = MockTiDB::instance().getDatabases(); | ||
for (auto it = databases.begin(); it != databases.end(); it++) | ||
{ | ||
auto db_id = it->second; | ||
auto db_name = it->first; | ||
TiDB::DBInfoPtr db_ptr = std::make_shared<TiDB::DBInfo>(TiDB::DBInfo()); | ||
db_ptr->id = db_id; | ||
db_ptr->name = db_name; | ||
res.push_back(db_ptr); | ||
} | ||
return res; | ||
} | ||
|
||
std::vector<TiDB::TableInfoPtr> listTables(Int64 db_id) | ||
{ | ||
auto tables_by_id = MockTiDB::instance().getTables(); | ||
std::vector<TiDB::TableInfoPtr> res; | ||
for (auto it = tables_by_id.begin(); it != tables_by_id.end(); it++) | ||
{ | ||
if (it->second->table_info.db_id == db_id) | ||
{ | ||
res.push_back(std::make_shared<TiDB::TableInfo>(TiDB::TableInfo(it->second->table_info))); | ||
} | ||
} | ||
return res; | ||
} | ||
}; | ||
|
||
} // namespace DB |
Oops, something went wrong.