Skip to content

Commit

Permalink
Update tests to current Jackson lib behavior (#31197)
Browse files Browse the repository at this point in the history
Co-authored-by: rodireich <[email protected]>
  • Loading branch information
rodireich and rodireich authored Oct 11, 2023
1 parent d309a2f commit 79080c8
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,22 +232,13 @@ protected void initTests() {
.addExpectedValues("0.188", null)
.build());

addDataTypeTestData(
TestDataHolder.builder()
.sourceType("decimal")
.airbyteType(JsonSchemaType.NUMBER)
.fullSourceDataType("decimal(19,2)")
.addInsertValues("1700000.01")
.addExpectedValues("1700000.01")
.build());

addDataTypeTestData(
TestDataHolder.builder()
.sourceType("decimal")
.airbyteType(JsonSchemaType.INTEGER)
.fullSourceDataType("decimal(32,0)")
.addInsertValues("1700000.01")
.addExpectedValues("1700000")
.addInsertValues("1700000.01", "123")
.addExpectedValues("1700000", "123")
.build());

for (final String type : Set.of("date", "date not null default '0000-00-00'")) {
Expand Down Expand Up @@ -451,6 +442,7 @@ protected void initTests() {
.addExpectedValues(null, "xs,s", "m,xl")
.build());

addDecimalValuesTest();
}

protected void addJsonDataTypeTest() {
Expand Down Expand Up @@ -492,4 +484,15 @@ private String getFileDataInBase64() {
return null;
}

protected void addDecimalValuesTest() {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("decimal")
.airbyteType(JsonSchemaType.NUMBER)
.fullSourceDataType("decimal(19,2)")
.addInsertValues("1700000.01", "'123'")
.addExpectedValues("1700000.01", "123.0")
.build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,16 @@ protected void addJsonDataTypeTest() {
.build());
}

@Override
protected void addDecimalValuesTest() {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("decimal")
.airbyteType(JsonSchemaType.NUMBER)
.fullSourceDataType("decimal(19,2)")
.addInsertValues("1700000.01", "'123'")
.addExpectedValues("1700000.01", "123.00")
.build());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,6 @@ protected void initTests() {
.addExpectedValues((String) null)
.build());

for (final String type : Set.of("double precision", "float", "float8")) {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType(type)
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues("'123'", "'1234567890.1234567'", "null")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'-Infinity'", "'Infinity'", "'NaN'", "null")
.addExpectedValues("123.0", "1.2345678901234567E9", null)
// "-Infinity", "Infinity", "NaN", null)
.build());
}

addDataTypeTestData(
TestDataHolder.builder()
.sourceType("inet")
Expand Down Expand Up @@ -320,38 +306,23 @@ protected void initTests() {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("numeric")
.fullSourceDataType("NUMERIC(38)")
.fullSourceDataType("NUMERIC(38,0)")
.airbyteType(JsonSchemaType.INTEGER)
.addInsertValues("'33'")
.addExpectedValues("33")
.build());

addDataTypeTestData(
TestDataHolder.builder()
.sourceType("numeric")
.fullSourceDataType("NUMERIC(28,2)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'14525.22'")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123", null, "14525.22")
.addInsertValues("'33'", "'123'")
.addExpectedValues("33", "123")
.build());

// Blocked by https://github.com/airbytehq/airbyte/issues/8902
for (final String type : Set.of("numeric", "decimal")) {
for (final String type : Set.of("double precision", "float", "float8")) {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType(type)
.fullSourceDataType("NUMERIC(20,7)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'1234567890.1234567'")
.addInsertValues("'123'", "'1234567890.1234567'", "null")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123", null, "1.2345678901234567E9")
// "'-Infinity'", "'Infinity'", "'NaN'", "null")
.addExpectedValues("123.0", "1.2345678901234567E9", null)
// "-Infinity", "Infinity", "NaN", null)
.build());
}

Expand Down Expand Up @@ -592,6 +563,7 @@ protected void initTests() {
addTimeWithTimeZoneTest();
addArraysTestData();
addMoneyTest();
addNumericValuesTest();
}

protected void addHstoreTest() {
Expand Down Expand Up @@ -966,4 +938,35 @@ private void addArraysTestData() {
.build());
}

protected void addNumericValuesTest() {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("numeric")
.fullSourceDataType("NUMERIC(28,2)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'14525.22'")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123.0", null, "14525.22")
.build());

// Blocked by https://github.com/airbytehq/airbyte/issues/8902
for (final String type : Set.of("numeric", "decimal")) {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType(type)
.fullSourceDataType("NUMERIC(20,7)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'1234567890.1234567'")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123.0", null, "1.2345678901234567E9")
.build());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,36 @@ protected void addTimestampWithInfinityValuesTest() {
}
}

@Override
protected void addNumericValuesTest() {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("numeric")
.fullSourceDataType("NUMERIC(28,2)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'14525.22'")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123", null, "14525.22")
.build());

// Blocked by https://github.com/airbytehq/airbyte/issues/8902
for (final String type : Set.of("numeric", "decimal")) {
addDataTypeTestData(
TestDataHolder.builder()
.sourceType(type)
.fullSourceDataType("NUMERIC(20,7)")
.airbyteType(JsonSchemaType.NUMBER)
.addInsertValues(
"'123'", "null", "'1234567890.1234567'")
// Postgres source does not support these special values yet
// https://github.com/airbytehq/airbyte/issues/8902
// "'infinity'", "'-infinity'", "'nan'"
.addExpectedValues("123", null, "1.2345678901234567E9")
.build());
}
}

}

0 comments on commit 79080c8

Please sign in to comment.