Skip to content

Commit

Permalink
Adding tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 16, 2023
1 parent 1194ea5 commit 3232865
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/typing/redshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func kindToRedShift(kd KindDetails) string {
return "VARCHAR(MAX)"
case String.Kind:
if kd.OptionalRedshiftStrPrecision != nil {
return fmt.Sprintf("VARCHAR(%d)", kd.OptionalRedshiftStrPrecision)
return fmt.Sprintf("VARCHAR(%d)", *kd.OptionalRedshiftStrPrecision)
}

return "VARCHAR(MAX)"
Expand Down
20 changes: 17 additions & 3 deletions lib/typing/typing_kind_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package typing

import (
"github.com/artie-labs/transfer/lib/config/constants"
"github.com/artie-labs/transfer/lib/ptr"
)

func (t *TypingTestSuite) Test_KindToDWHType() {
type _tc struct {
kd KindDetails
Expand All @@ -15,11 +20,20 @@ func (t *TypingTestSuite) Test_KindToDWHType() {
expectedBigQueryType: "string",
expectedRedshiftType: "VARCHAR(MAX)",
},
{
kd: KindDetails{
Kind: String.Kind,
OptionalRedshiftStrPrecision: ptr.ToInt(12345),
},
expectedSnowflakeType: "string",
expectedBigQueryType: "string",
expectedRedshiftType: "VARCHAR(12345)",
},
}

for idx, tc := range tcs {
t.Equal(tc.expectedSnowflakeType, kindToSnowflake(tc.kd), idx)
t.Equal(tc.expectedBigQueryType, kindToBigQuery(tc.kd), idx)
t.Equal(tc.expectedRedshiftType, kindToRedShift(tc.kd), idx)
t.Equal(tc.expectedSnowflakeType, KindToDWHType(tc.kd, constants.Snowflake), idx)
t.Equal(tc.expectedBigQueryType, KindToDWHType(tc.kd, constants.BigQuery), idx)
t.Equal(tc.expectedRedshiftType, KindToDWHType(tc.kd, constants.Redshift), idx)
}
}

0 comments on commit 3232865

Please sign in to comment.