Skip to content

Commit

Permalink
Fix all tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 28, 2024
1 parent 3db64f5 commit 765a34b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 4 additions & 6 deletions lib/cdc/mongo/debezium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/json"
"time"

"github.com/artie-labs/transfer/lib/typing/ext"

"github.com/artie-labs/transfer/lib/config/constants"
"github.com/artie-labs/transfer/lib/debezium"
"github.com/artie-labs/transfer/lib/kafkalib"
Expand Down Expand Up @@ -179,11 +177,11 @@ func (m *MongoTestSuite) TestMongoDBEventCustomer() {
evtDataWithIncludedAt, err = evt.GetData(map[string]any{"_id": int64(1003)}, kafkalib.TopicConfig{IncludeDatabaseUpdatedAt: true, IncludeArtieUpdatedAt: true})
assert.NoError(m.T(), err)

assert.Equal(m.T(), ext.NewExtendedTime(time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC), ext.TimestampTZKindType, ext.ISO8601), evtDataWithIncludedAt[constants.DatabaseUpdatedColumnMarker])
assert.Equal(m.T(), time.Date(2022, time.November, 18, 6, 35, 21, 0, time.UTC), evtDataWithIncludedAt[constants.DatabaseUpdatedColumnMarker])

updatedExtTime, isOk := evtDataWithIncludedAt[constants.UpdateColumnMarker].(*ext.ExtendedTime)
updatedTime, isOk := evtDataWithIncludedAt[constants.UpdateColumnMarker].(time.Time)
assert.True(m.T(), isOk)
assert.False(m.T(), updatedExtTime.GetTime().IsZero())
assert.False(m.T(), updatedTime.IsZero())

var nestedData map[string]any
err = json.Unmarshal([]byte(evtData["nested"].(string)), &nestedData)
Expand Down Expand Up @@ -314,7 +312,7 @@ func (m *MongoTestSuite) TestMongoDBEventCustomerBefore() {

updatedAt, isOk := evtData[constants.UpdateColumnMarker]
assert.True(m.T(), isOk)
_, isOk = updatedAt.(*ext.ExtendedTime)
_, isOk = updatedAt.(time.Time)
assert.True(m.T(), isOk)
}
}
Expand Down
16 changes: 8 additions & 8 deletions lib/typing/mongo/bson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ func TestJSONEToMap(t *testing.T) {
}
{
// Date
extendedTime, isOk := result["order_date"].(*ext.ExtendedTime)
ts, isOk := result["order_date"].(time.Time)
assert.True(t, isOk)
assert.Equal(t, ext.NewExtendedTime(time.Date(2016, time.February, 21, 0, 0, 0, 0, time.UTC), ext.TimestampTZKindType, ext.ISO8601), extendedTime)
assert.Equal(t, time.Date(2016, time.February, 21, 0, 0, 0, 0, time.UTC), ts)
}
{
// Timestamp
extendedTime, isOk := result["test_timestamp"]
ts, isOk := result["test_timestamp"]
assert.True(t, isOk)
assert.Equal(t, ext.NewExtendedTime(time.Date(2023, time.March, 16, 1, 18, 37, 0, time.UTC), ext.TimestampTZKindType, ext.ISO8601), extendedTime)
assert.Equal(t, "2023-03-16T01:18:37+00:00", extendedTime.(*ext.ExtendedTime).GetTime().Format(ext.ISO8601))
assert.Equal(t, time.Date(2023, time.March, 16, 1, 18, 37, 0, time.UTC), ts)
assert.Equal(t, "2023-03-16T01:18:37+00:00", ts.(time.Time).Format(ext.ISO8601))
}
{
// Boolean
Expand Down Expand Up @@ -220,10 +220,10 @@ func TestBsonValueToGoValue(t *testing.T) {
result, err := bsonValueToGoValue(dateTime)
assert.NoError(t, err)

extendedTime, isOk := result.(*ext.ExtendedTime)
ts, isOk := result.(time.Time)
assert.True(t, isOk)
assert.Equal(t, ext.NewExtendedTime(time.Date(2021, time.January, 1, 0, 0, 0, 0, time.UTC), ext.TimestampTZKindType, ext.ISO8601), extendedTime)
assert.Equal(t, "2021-01-01T00:00:00+00:00", extendedTime.GetTime().Format(ext.ISO8601))
assert.Equal(t, time.Date(2021, time.January, 1, 0, 0, 0, 0, time.UTC), ts)
assert.Equal(t, "2021-01-01T00:00:00+00:00", ts.Format(ext.ISO8601))
}
{
// primitive.ObjectID
Expand Down

0 comments on commit 765a34b

Please sign in to comment.