Skip to content

Commit

Permalink
adds sf condition for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Amogh-Bharadwaj committed Oct 16, 2023
1 parent 225b637 commit d64aaba
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions flow/e2e/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ func PopulateSourceTable(pool *pgxpool.Pool, suffix string, tableName string, ro
for i := 0; i < rowCount-1; i++ {
id := uuid.New().String()
ids = append(ids, id)
geoValues := ""
if strings.Contains(tableName, "sf") {
// geo types
geoValues = `,'POINT(1 2)','POINT(40.7128 -74.0060)',
'LINESTRING(0 0, 1 1, 2 2)',
'LINESTRING(-74.0060 40.7128, -73.9352 40.7306, -73.9123 40.7831)',
'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))',
'POLYGON((-74.0060 40.7128, -73.9352 40.7306, -73.9123 40.7831, -74.0060 40.7128))'`
}
row := fmt.Sprintf(`
(
'%s', '%s', CURRENT_TIMESTAMP, 3.86487206688919, CURRENT_TIMESTAMP,
Expand All @@ -204,18 +213,19 @@ func PopulateSourceTable(pool *pgxpool.Pool, suffix string, tableName string, ro
CURRENT_TIMESTAMP, 1, ARRAY['text1', 'text2'], ARRAY[123, 456], ARRAY[789, 012],
ARRAY['varchar1', 'varchar2'], '{"key": 8.5}',
'[{"key1": "value1", "key2": "value2", "key3": "value3"}]',
'{"key": "value"}', 15,
'POINT(1 2)','POINT(40.7128 -74.0060)',
'LINESTRING(0 0, 1 1, 2 2)',
'LINESTRING(-74.0060 40.7128, -73.9352 40.7306, -73.9123 40.7831)',
'POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))',
'POLYGON((-74.0060 40.7128, -73.9352 40.7306, -73.9123 40.7831, -74.0060 40.7128))'
'{"key": "value"}', 15 %s
)`,
id, uuid.New().String(), uuid.New().String(),
uuid.New().String(), uuid.New().String(), uuid.New().String(), uuid.New().String())
uuid.New().String(), uuid.New().String(), uuid.New().String(), uuid.New().String(), geoValues)
rows = append(rows, row)
}

geoColumns := ""
if strings.Contains(tableName, "sf") {
geoColumns = ",geometry_point, geography_point," +
"geometry_linestring, geography_linestring," +
"geometry_polygon, geography_polygon"
}
_, err := pool.Exec(context.Background(), fmt.Sprintf(`
INSERT INTO e2e_test_%s.%s (
id, card_id, "from", price, created_at,
Expand All @@ -224,12 +234,10 @@ func PopulateSourceTable(pool *pgxpool.Pool, suffix string, tableName string, ro
deal_id, ethereum_transaction_id, ignore_price, card_eth_value,
paid_eth_price, card_bought_notified, address, account_id,
asset_id, status, transaction_id, settled_at, reference_id,
settle_at, settlement_delay_reason, f1, f2, f3, f4, f5, f6, f7, f8,
geometry_point, geography_point,
geometry_linestring, geography_linestring,
geometry_polygon, geography_polygon
settle_at, settlement_delay_reason, f1, f2, f3, f4, f5, f6, f7, f8
%s
) VALUES %s;
`, suffix, tableName, strings.Join(rows, ",")))
`, suffix, tableName, geoColumns, strings.Join(rows, ",")))
if err != nil {
return err
}
Expand Down

0 comments on commit d64aaba

Please sign in to comment.