Skip to content

Commit

Permalink
Fixes broken end to end test (#3050)
Browse files Browse the repository at this point in the history
  • Loading branch information
alishakawaguchi authored Dec 13, 2024
1 parent 241feb0 commit ca4d3ee
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 52 deletions.
8 changes: 4 additions & 4 deletions cli/internal/cmds/neosync/sync/sync_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func Test_Sync(t *testing.T) {
require.Equal(t, `{"name": "John", "age": 30}`, jsonVal)
require.Equal(t, `{"age": 30, "name": "John"}`, jsonbVal) // Note: JSONB reorders keys

err = verifyPostgresTimeTimeTableValues(t, ctx, postgres.Target.DB)
err = verifyPostgresTimeTimeTableValues(t, ctx, postgres.Target.DB, "alltypes")
require.NoError(t, err)
})

Expand Down Expand Up @@ -248,7 +248,7 @@ func Test_Sync(t *testing.T) {
require.Equal(t, `{"age":30,"name":"John"}`, jsonVal)
require.Equal(t, `{"age": 30, "name": "John"}`, jsonbVal) // Note: JSONB reorders keys

err = verifyPostgresTimeTimeTableValues(t, ctx, postgres.Target.DB)
err = verifyPostgresTimeTimeTableValues(t, ctx, postgres.Target.DB, alltypesSchema)
require.NoError(t, err)
})

Expand Down Expand Up @@ -440,8 +440,8 @@ func Test_Sync(t *testing.T) {
})
}

func verifyPostgresTimeTimeTableValues(t *testing.T, ctx context.Context, db *pgxpool.Pool) error {
rows, err := db.Query(ctx, "select timestamp_col::text, date_col::text from alltypes.time_time;")
func verifyPostgresTimeTimeTableValues(t *testing.T, ctx context.Context, db *pgxpool.Pool, schema string) error {
rows, err := db.Query(ctx, fmt.Sprintf("select timestamp_col::text, date_col::text from %q.time_time;", schema))
if err != nil {
return err
}
Expand Down
105 changes: 57 additions & 48 deletions internal/testutil/testdata/postgres/alltypes/create-tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,21 @@ VALUES (

CREATE TABLE IF NOT EXISTS array_types (
"id" BIGINT NOT NULL PRIMARY KEY,
-- "int_array" _int4,
-- "smallint_array" _int2,
-- "bigint_array" _int8,
-- "real_array" _float4,
-- "double_array" _float8,
-- "text_array" _text,
-- "varchar_array" _varchar,
-- "char_array" _bpchar,
-- "boolean_array" _bool,
-- "date_array" _date,
"int_array" _int4,
"smallint_array" _int2,
"bigint_array" _int8,
"real_array" _float4,
"double_array" _float8,
"text_array" _text,
"varchar_array" _varchar,
"char_array" _bpchar,
"boolean_array" _bool,
"date_array" _date,
-- "time_array" _time,
-- "timestamp_array" _timestamp,
-- "timestamptz_array" _timestamptz,
"timestamp_array" _timestamp,
"timestamptz_array" _timestamptz,
"interval_array" _interval,
-- "inet_array" _inet, // broken
-- "inet_array" _inet,
-- "cidr_array" _cidr,
-- "point_array" _point,
-- "line_array" _line,
Expand All @@ -255,52 +255,61 @@ CREATE TABLE IF NOT EXISTS array_types (
-- "path_array" _path,
-- "polygon_array" _polygon,
-- "circle_array" _circle,
"uuid_array" _uuid
-- "json_array" _json,
-- "jsonb_array" _jsonb,
"uuid_array" _uuid,
"json_array" _json,
"jsonb_array" _jsonb,
-- "bit_array" _bit,
-- "varbit_array" _varbit,
-- "numeric_array" _numeric,
-- "money_array" _money,
-- "xml_array" _xml
"numeric_array" _numeric,
"money_array" _money,
"xml_array" _xml
-- "int_double_array" _int4
);



INSERT INTO array_types (
id,
-- int_array, smallint_array, bigint_array,
-- real_array,
-- double_array,
-- text_array, varchar_array, char_array, boolean_array,
-- date_array,
-- time_array, timestamp_array, timestamptz_array,
int_array,
smallint_array,
bigint_array,
real_array,
double_array,
text_array,
varchar_array,
char_array,
boolean_array,
date_array,
-- time_array,
timestamp_array,
timestamptz_array,
interval_array,
-- inet_array, cidr_array,
-- point_array, line_array, lseg_array,
-- box_array,
-- path_array, polygon_array, circle_array,
uuid_array
-- json_array, jsonb_array,
-- bit_array, varbit_array, numeric_array,
-- money_array,
-- xml_array
uuid_array,
json_array, jsonb_array,
-- bit_array, varbit_array,
numeric_array,
money_array,
xml_array
-- int_double_array
) VALUES (
1,
-- ARRAY[1, 2, 3],
-- ARRAY[10::smallint, 20::smallint],
-- ARRAY[100::bigint, 200::bigint],
-- ARRAY[1.1::real, 2.2::real],
-- ARRAY[1.11::double precision, 2.22::double precision],
-- ARRAY['text1', 'text2'],
-- ARRAY['varchar1'::varchar, 'varchar2'::varchar],
-- ARRAY['a'::char, 'b'::char],
-- ARRAY[true, false],
-- ARRAY['2023-01-01'::date, '2023-01-02'::date],
ARRAY[1, 2, 3],
ARRAY[10::smallint, 20::smallint],
ARRAY[100::bigint, 200::bigint],
ARRAY[1.1::real, 2.2::real],
ARRAY[1.11::double precision, 2.22::double precision],
ARRAY['text1', 'text2'],
ARRAY['varchar1'::varchar, 'varchar2'::varchar],
ARRAY['a'::char, 'b'::char],
ARRAY[true, false],
ARRAY['2023-01-01'::date, '2023-01-02'::date],
-- ARRAY['12:00:00'::time, '13:00:00'::time],
-- ARRAY['2023-01-01 12:00:00'::timestamp, '2023-01-02 13:00:00'::timestamp],
-- ARRAY['2023-01-01 12:00:00+00'::timestamptz, '2023-01-02 13:00:00+00'::timestamptz],
ARRAY['2023-01-01 12:00:00'::timestamp, '2023-01-02 13:00:00'::timestamp],
ARRAY['2023-01-01 12:00:00+00'::timestamptz, '2023-01-02 13:00:00+00'::timestamptz],
ARRAY['1 day'::interval, '2 hours'::interval],
-- ARRAY['192.168.0.1'::inet, '10.0.0.1'::inet],
-- ARRAY['192.168.0.0/24'::cidr, '10.0.0.0/8'::cidr],
Expand All @@ -311,14 +320,14 @@ INSERT INTO array_types (
-- ARRAY['((1,1),(2,2),(3,3))'::path, '((4,4),(5,5),(6,6))'::path],
-- ARRAY['((1,1),(2,2),(3,3))'::polygon, '((4,4),(5,5),(6,6))'::polygon],
-- ARRAY['<(1,1),1>'::circle, '<(2,2),2>'::circle],
ARRAY['a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, 'b0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid]
-- ARRAY['{"key": "value1"}'::json, '{"key": "value2"}'::json],
-- ARRAY['{"key": "value1"}'::jsonb, '{"key": "value2"}'::jsonb],
ARRAY['a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid, 'b0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'::uuid],
ARRAY['{"key": "value1"}'::json, '{"key": "value2"}'::json],
ARRAY['{"key": "value1"}'::jsonb, '{"key": "value2"}'::jsonb],
-- ARRAY['101'::bit(3), '110'::bit(3)],
-- ARRAY['10101'::bit varying(5), '01010'::bit varying(5)],
-- ARRAY[1.23::numeric, 4.56::numeric],
-- ARRAY[10.00::money, 20.00::money],
-- ARRAY['<root>value1</root>'::xml, '<root>value2</root>'::xml]
ARRAY[1.23::numeric, 4.56::numeric],
ARRAY[10.00::money, 20.00::money],
ARRAY['<root>value1</root>'::xml, '<root>value2</root>'::xml]
-- ARRAY[[1, 2], [3, 4]]
);

Expand Down

0 comments on commit ca4d3ee

Please sign in to comment.