// MockInfoSchema only serves for test. func MockInfoSchema(tbList []*model.TableInfo) InfoSchema { result := &infoSchema{} result.schemaNameToID = make(map[string]int64) result.tableNameToID = make(map[tableName]int64) result.schemas = make(map[int64]*model.DBInfo) result.tables = make(map[int64]table.Table) result.schemaNameToID["test"] = 0 result.schemas[0] = &model.DBInfo{ID: 0, Name: model.NewCIStr("test"), Tables: tbList} for i, tb := range tbList { result.tableNameToID[tableName{schema: "test", table: tb.Name.L}] = int64(i) result.tables[int64(i)] = table.MockTableFromMeta(tb) } return result }
// MockInfoSchema only serves for test. func MockInfoSchema(tbList []*model.TableInfo) InfoSchema { result := &infoSchema{} result.schemaMap = make(map[string]*schemaTables) result.sortedTablesBuckets = make([]sortedTables, bucketCount) dbInfo := &model.DBInfo{ID: 0, Name: model.NewCIStr("test"), Tables: tbList} tableNames := &schemaTables{ dbInfo: dbInfo, tables: make(map[string]table.Table), } result.schemaMap["test"] = tableNames for _, tb := range tbList { tbl := table.MockTableFromMeta(tb) tableNames.tables[tb.Name.L] = tbl bucketIdx := tableBucketIdx(tb.ID) result.sortedTablesBuckets[bucketIdx] = append(result.sortedTablesBuckets[bucketIdx], tbl) } for i := range result.sortedTablesBuckets { sort.Sort(result.sortedTablesBuckets[i]) } return result }