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

Function TestSchemaMetadata_DropTable

backend/store/model/database_test.go:178–207  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func TestSchemaMetadata_DropTable(t *testing.T) {
179 metadata := &storepb.DatabaseSchemaMetadata{
180 Name: "testdb",
181 Schemas: []*storepb.SchemaMetadata{
182 {
183 Name: "public",
184 Tables: []*storepb.TableMetadata{
185 {Name: "users"},
186 {Name: "products"},
187 },
188 },
189 },
190 }
191
192 schema := NewDatabaseMetadata(metadata, nil, nil, storepb.Engine_POSTGRES, true)
193 schemaMeta := schema.GetSchemaMetadata("public")
194
195 // Drop table
196 err := schemaMeta.DropTable("users")
197
198 require.Nil(t, err)
199
200 // Verify table is gone
201 retrieved := schemaMeta.GetTable("users")
202 require.Nil(t, retrieved)
203
204 // Verify other table still exists
205 retrieved = schemaMeta.GetTable("products")
206 require.NotNil(t, retrieved)
207}
208
209func TestSchemaMetadata_DropTable_NotExists(t *testing.T) {
210 metadata := &storepb.DatabaseSchemaMetadata{

Callers

nothing calls this directly

Calls 4

GetSchemaMetadataMethod · 0.95
NewDatabaseMetadataFunction · 0.85
DropTableMethod · 0.80
GetTableMethod · 0.45

Tested by

no test coverage detected