Skip to content

Commit

Permalink
Adding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Nov 15, 2024
1 parent c09bb79 commit 57a0943
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/destination/ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ func TestBuildCreateTableSQL(t *testing.T) {
}
}

func TestBuildAlterTableAddColumns(t *testing.T) {
{
// No columns
sqlParts := BuildAlterTableAddColumns(nil, nil, []columns.Column{})
assert.Empty(t, sqlParts)
}
{
// One column to add
sqlParts := BuildAlterTableAddColumns(dialect.RedshiftDialect{}, dialect.NewTableIdentifier("schema", "table"), []columns.Column{columns.NewColumn("dusty", typing.String)})
assert.Len(t, sqlParts, 1)
assert.Equal(t, `ALTER TABLE schema."table" add COLUMN "dusty" VARCHAR(MAX)`, sqlParts[0])
}
{
// Three columns to add
sqlParts := BuildAlterTableAddColumns(dialect.RedshiftDialect{}, dialect.NewTableIdentifier("schema", "table"),
[]columns.Column{
columns.NewColumn("aussie", typing.String),
columns.NewColumn("doge", typing.String),
columns.NewColumn("age", typing.Integer),
},
)

assert.Len(t, sqlParts, 3)
assert.Equal(t, `ALTER TABLE schema."table" add COLUMN "aussie" VARCHAR(MAX)`, sqlParts[0])
assert.Equal(t, `ALTER TABLE schema."table" add COLUMN "doge" VARCHAR(MAX)`, sqlParts[1])
assert.Equal(t, `ALTER TABLE schema."table" add COLUMN "age" INT8`, sqlParts[2])
}
}

func TestAlterTableArgs_Validate(t *testing.T) {
{
// Invalid
Expand Down

0 comments on commit 57a0943

Please sign in to comment.