Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 23, 2024
1 parent 79210b1 commit da8e465
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/debezium/converters/time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestTime_Convert(t *testing.T) {
}

func TestNanoTime_Converter(t *testing.T) {
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, NanoTime{}.layout()), NanoTime{}.ToKindDetails())
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, NanoTime{}.layout()), NanoTime{}.ToKindDetails())
{
// Invalid data
_, err := NanoTime{}.Convert("123")
Expand All @@ -158,7 +158,7 @@ func TestNanoTime_Converter(t *testing.T) {
}

func TestMicroTime_Converter(t *testing.T) {
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, MicroTime{}.layout()), MicroTime{}.ToKindDetails())
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, MicroTime{}.layout()), MicroTime{}.ToKindDetails())
{
// Invalid data
_, err := MicroTime{}.Convert("123")
Expand Down
6 changes: 3 additions & 3 deletions lib/debezium/converters/timestamp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestTimestamp_Converter(t *testing.T) {
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MillisecondNoTZ), Timestamp{}.ToKindDetails())
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MillisecondNoTZ), Timestamp{}.ToKindDetails())
{
// Invalid conversion
_, err := Timestamp{}.Convert("invalid")
Expand All @@ -30,7 +30,7 @@ func TestTimestamp_Converter(t *testing.T) {
}

func TestMicroTimestamp_Converter(t *testing.T) {
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MicrosecondNoTZ), MicroTimestamp{}.ToKindDetails())
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MicrosecondNoTZ), MicroTimestamp{}.ToKindDetails())
{
// Invalid conversion
_, err := MicroTimestamp{}.Convert("invalid")
Expand All @@ -51,7 +51,7 @@ func TestMicroTimestamp_Converter(t *testing.T) {
}

func TestNanoTimestamp_Converter(t *testing.T) {
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339NanosecondNoTZ), NanoTimestamp{}.ToKindDetails())
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339NanosecondNoTZ), NanoTimestamp{}.ToKindDetails())
{
// Invalid conversion
_, err := NanoTimestamp{}.Convert("invalid")
Expand Down
12 changes: 6 additions & 6 deletions lib/debezium/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func TestField_ToKindDetails(t *testing.T) {
for _, dbzType := range []SupportedDebeziumType{ZonedTimestamp} {
kd, err := Field{DebeziumType: dbzType}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "2006-01-02T15:04:05.999999999Z"), kd)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "2006-01-02T15:04:05.999999999Z"), kd)
}
}
{
Expand All @@ -250,7 +250,7 @@ func TestField_ToKindDetails(t *testing.T) {
for _, dbzType := range []SupportedDebeziumType{Date, DateKafkaConnect} {
kd, err := Field{DebeziumType: dbzType}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ext.PostgresDateFormat), kd)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ext.PostgresDateFormat), kd)
}
}
{
Expand All @@ -259,28 +259,28 @@ func TestField_ToKindDetails(t *testing.T) {
for _, dbzType := range []SupportedDebeziumType{TimeWithTimezone} {
kd, err := Field{DebeziumType: dbzType}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.999999Z"), kd, dbzType)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.999999Z"), kd, dbzType)
}
}
{
// Time
for _, dbzType := range []SupportedDebeziumType{Time, TimeKafkaConnect} {
kd, err := Field{DebeziumType: dbzType}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000"), kd, dbzType)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000"), kd, dbzType)
}
}
{
// Micro time
kd, err := Field{DebeziumType: MicroTime}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000000"), kd)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000000"), kd)
}
{
// Nano time
kd, err := Field{DebeziumType: NanoTime}.ToKindDetails()
assert.NoError(t, err)
assert.Equal(t, typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000000000"), kd)
assert.Equal(t, typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, "15:04:05.000000000"), kd)
}
}
{
Expand Down
8 changes: 4 additions & 4 deletions lib/destination/ddl/ddl_sflk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (d *DDLTestSuite) TestAlterComplexObjects() {

func (d *DDLTestSuite) TestAlterIdempotency() {
cols := []columns.Column{
columns.NewColumn("created_at", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("created_at", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("id", typing.Integer),
columns.NewColumn("order_name", typing.String),
columns.NewColumn("start", typing.String),
Expand Down Expand Up @@ -81,7 +81,7 @@ func (d *DDLTestSuite) TestAlterIdempotency() {
func (d *DDLTestSuite) TestAlterTableAdd() {
// Test adding a bunch of columns
cols := []columns.Column{
columns.NewColumn("created_at", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("created_at", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("id", typing.Integer),
columns.NewColumn("order_name", typing.String),
columns.NewColumn("start", typing.String),
Expand Down Expand Up @@ -123,7 +123,7 @@ func (d *DDLTestSuite) TestAlterTableAdd() {
func (d *DDLTestSuite) TestAlterTableDeleteDryRun() {
// Test adding a bunch of columns
cols := []columns.Column{
columns.NewColumn("created_at", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("created_at", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("id", typing.Integer),
columns.NewColumn("name", typing.String),
columns.NewColumn("start", typing.String),
Expand Down Expand Up @@ -180,7 +180,7 @@ func (d *DDLTestSuite) TestAlterTableDeleteDryRun() {
func (d *DDLTestSuite) TestAlterTableDelete() {
// Test adding a bunch of columns
cols := []columns.Column{
columns.NewColumn("created_at", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("created_at", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")),
columns.NewColumn("id", typing.Integer),
columns.NewColumn("name", typing.String),
columns.NewColumn("col_to_delete", typing.String),
Expand Down
14 changes: 7 additions & 7 deletions lib/optimization/table_data_merge_columns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ func TestTableData_UpdateInMemoryColumnsFromDestination_Tz(t *testing.T) {
{
// In memory and destination columns are both timestamp_tz
tableData := &TableData{inMemoryColumns: &columns.Columns{}}
tableData.AddInMemoryCol(columns.NewColumn("foo", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")))
tableData.AddInMemoryCol(columns.NewColumn("foo", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, "")))

assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("foo", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("foo", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))
updatedColumn, isOk := tableData.inMemoryColumns.GetColumn("foo")
assert.True(t, isOk)
assert.Equal(t, ext.TimestampTZKindType, updatedColumn.KindDetails.ExtendedTimeDetails.Type)
Expand All @@ -27,11 +27,11 @@ func TestTableData_UpdateInMemoryColumnsFromDestination_Tz(t *testing.T) {
tableData.AddInMemoryCol(
columns.NewColumn(
"foo",
typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MillisecondNoTZ),
typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampNTZKindType, ext.RFC3339MillisecondNoTZ),
),
)

assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("foo", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("foo", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))
updatedColumn, isOk := tableData.inMemoryColumns.GetColumn("foo")
assert.True(t, isOk)
assert.Equal(t, ext.TimestampTZKindType, updatedColumn.KindDetails.ExtendedTimeDetails.Type)
Expand Down Expand Up @@ -137,9 +137,9 @@ func TestTableData_UpdateInMemoryColumnsFromDestination(t *testing.T) {
assert.Nil(t, col.KindDetails.ExtendedTimeDetails, extTimeDetailsCol)
}

assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_time", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_date", typing.OldNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_datetime", typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_time", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimeKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_date", typing.MustNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ""))))
assert.NoError(t, tableData.MergeColumnsFromDestination(columns.NewColumn("ext_datetime", typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""))))

dateCol, isOk := tableData.inMemoryColumns.GetColumn("ext_date")
assert.True(t, isOk)
Expand Down
6 changes: 3 additions & 3 deletions lib/optimization/table_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func TestTableData_UpdateInMemoryColumns(t *testing.T) {
"FOO": typing.String,
"bar": typing.Invalid,
"CHANGE_me": typing.String,
"do_not_change_format": typing.OldNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ""),
"do_not_change_format": typing.MustNewExtendedTimeDetails(typing.ETime, ext.DateKindType, ""),
} {
_cols.AddColumn(columns.NewColumn(colName, colKind))
}
Expand All @@ -150,9 +150,9 @@ func TestTableData_UpdateInMemoryColumns(t *testing.T) {

for name, colKindDetails := range map[string]typing.KindDetails{
"foo": typing.String,
"change_me": typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""),
"change_me": typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""),
"bar": typing.Boolean,
"do_not_change_format": typing.OldNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""),
"do_not_change_format": typing.MustNewExtendedTimeDetails(typing.ETime, ext.TimestampTZKindType, ""),
} {
tableData.MergeColumnsFromDestination(columns.NewColumn(name, colKindDetails))
}
Expand Down

0 comments on commit da8e465

Please sign in to comment.