Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 18, 2024
1 parent d5c2aea commit e7ca6a0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions sources/mysql/streaming/ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,44 @@ func TestSchemaAdapter_SQLMode(t *testing.T) {
}
}

func TestSchemaAdapter_ColumnFiltering(t *testing.T) {
{
// Excluding column [exclude_me]
adapter := NewSchemaAdapter(config.MySQL{Database: "foo", Tables: []*config.MySQLTable{{Name: "test_table", ExcludeColumns: []string{"exclude_me"}}}}, nil)
assert.Equal(t, "foo", adapter.dbName)

assert.NoError(t, adapter.ApplyDDL(99, "CREATE TABLE test_table (id INT PRIMARY KEY, exclude_me VARCHAR(255));"))
assert.Len(t, adapter.adapters, 1)

tblAdapter, ok := adapter.GetTableAdapter("test_table")
assert.True(t, ok)

assert.Len(t, tblAdapter.columns, 2)

parsedCols, err := tblAdapter.buildParsedColumns()
assert.NoError(t, err)
assert.Len(t, parsedCols, 1)
assert.Equal(t, "id", parsedCols[0].Name)
}
{
// Not excluding
adapter := NewSchemaAdapter(config.MySQL{Database: "foo", Tables: []*config.MySQLTable{{Name: "test_table"}}}, nil)
assert.Equal(t, "foo", adapter.dbName)

assert.NoError(t, adapter.ApplyDDL(99, "CREATE TABLE test_table (id INT PRIMARY KEY, name VARCHAR(255));"))
assert.Len(t, adapter.adapters, 1)

tblAdapter, ok := adapter.GetTableAdapter("test_table")
assert.True(t, ok)

assert.Len(t, tblAdapter.columns, 2)

parsedCols, err := tblAdapter.buildParsedColumns()
assert.NoError(t, err)
assert.Len(t, parsedCols, 2)
}
}

func TestSchemaAdapter_ApplyDDL(t *testing.T) {
{
// Column rename
Expand Down

0 comments on commit e7ca6a0

Please sign in to comment.