MCPcopy Index your code
hub / github.com/bytebase/bytebase / TestGetLatestSchema

Function TestGetLatestSchema

backend/tests/schema_update_test.go:108–321  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

106}
107
108func TestGetLatestSchema(t *testing.T) {
109 tests := []struct {
110 name string
111 dbType storepb.Engine
112 instanceID string
113 databaseName string
114 ddl string
115 wantRawSchema string
116 wantDatabaseMetadata *v1pb.DatabaseMetadata
117 }{
118 {
119 name: "MySQL",
120 dbType: storepb.Engine_MYSQL,
121 instanceID: "latest-schema-mysql",
122 databaseName: "latestSchema",
123 ddl: `CREATE TABLE book(id INT, name TEXT);`,
124 wantRawSchema: "SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;\n" +
125 "SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;\n" +
126 "--\n" +
127 "-- Table structure for `book`\n" +
128 "--\n" +
129 "CREATE TABLE `book` (\n" +
130 " `id` int DEFAULT NULL,\n" +
131 " `name` text DEFAULT NULL\n" +
132 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;\n\n" +
133 "SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;\n" +
134 "SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;\n",
135 wantDatabaseMetadata: &v1pb.DatabaseMetadata{
136 Name: "instances/latest-schema-mysql/databases/latestSchema/metadata",
137 CharacterSet: "utf8mb4",
138 Collation: "utf8mb4_general_ci",
139 Schemas: []*v1pb.SchemaMetadata{
140 {
141 Tables: []*v1pb.TableMetadata{
142 {
143 Name: "book",
144 Engine: "InnoDB",
145 Collation: "utf8mb4_general_ci",
146 Charset: "utf8mb4",
147 DataSize: 16384,
148 Columns: []*v1pb.ColumnMetadata{
149 {
150 Name: "id",
151 Position: 1,
152 Nullable: true,
153 HasDefault: true,
154 Default: "NULL",
155 Type: "int",
156 },
157 {
158 Name: "name",
159 Position: 2,
160 Nullable: true,
161 Type: "text",
162 HasDefault: true,
163 Default: "NULL",
164 CharacterSet: "utf8mb4",
165 Collation: "utf8mb4_general_ci",

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
createEnvironmentMethod · 0.95
createDatabaseMethod · 0.95
changeDatabaseMethod · 0.95
getPgContainerFunction · 0.85
getMySQLContainerFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65
CreateInstanceMethod · 0.65
GetDatabaseMethod · 0.65
CreateSheetMethod · 0.65

Tested by

no test coverage detected