Skip to content

Commit

Permalink
tests: jsonb array testing
Browse files Browse the repository at this point in the history
  • Loading branch information
asthamohta committed Dec 26, 2022
1 parent 337907c commit 43a3a39
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
10 changes: 10 additions & 0 deletions tests/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,23 @@
CREATE TABLE all_types (
pkey BIGINT NOT NULL,
int_value INT,
int_array INT[],
bool_value BOOL,
bool_array BOOL[],
bytes_value BYTEA,
bytes_array BYTEA[],
float_value DOUBLE PRECISION,
float_array DOUBLE PRECISION[],
string_value VARCHAR(16),
string_array VARCHAR(16)[],
date_value DATE,
date_array DATE[],
timestamp_value TIMESTAMPTZ,
timestamp_array TIMESTAMPTZ[],
numeric_value NUMERIC,
numeric_array NUMERIC[],
jsonb_value JSONB,
jsonb_array JSONB[],
PRIMARY KEY (pkey) );
CREATE TABLE counters (
name VARCHAR(1024),
Expand Down
29 changes: 24 additions & 5 deletions tests/system/test_session_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@

EMULATOR_ALL_TYPES_COLUMNS = LIVE_ALL_TYPES_COLUMNS[:-4]
# ToDo: Clean up generation of POSTGRES_ALL_TYPES_COLUMNS
POSTGRES_ALL_TYPES_COLUMNS = (
LIVE_ALL_TYPES_COLUMNS[:1]
+ LIVE_ALL_TYPES_COLUMNS[1:7:2]
+ LIVE_ALL_TYPES_COLUMNS[9:17:2]
+ ("jsonb_value",)
POSTGRES_ALL_TYPES_COLUMNS = LIVE_ALL_TYPES_COLUMNS[:17] + (
"jsonb_value",
"jsonb_array",
)

AllTypesRowData = collections.namedtuple("AllTypesRowData", LIVE_ALL_TYPES_COLUMNS)
Expand Down Expand Up @@ -180,12 +178,33 @@
PostGresAllTypesRowData(pkey=101, int_value=123),
PostGresAllTypesRowData(pkey=102, bool_value=False),
PostGresAllTypesRowData(pkey=103, bytes_value=BYTES_1),
PostGresAllTypesRowData(pkey=104, date_value=SOME_DATE),
PostGresAllTypesRowData(pkey=105, float_value=1.4142136),
PostGresAllTypesRowData(pkey=106, string_value="VALUE"),
PostGresAllTypesRowData(pkey=107, timestamp_value=SOME_TIME),
PostGresAllTypesRowData(pkey=108, timestamp_value=NANO_TIME),
PostGresAllTypesRowData(pkey=109, numeric_value=NUMERIC_1),
PostGresAllTypesRowData(pkey=110, jsonb_value=JSON_1),
# empty array values
PostGresAllTypesRowData(pkey=201, int_array=[]),
PostGresAllTypesRowData(pkey=202, bool_array=[]),
PostGresAllTypesRowData(pkey=203, bytes_array=[]),
PostGresAllTypesRowData(pkey=204, date_array=[]),
PostGresAllTypesRowData(pkey=205, float_array=[]),
PostGresAllTypesRowData(pkey=206, string_array=[]),
PostGresAllTypesRowData(pkey=207, timestamp_array=[]),
PostGresAllTypesRowData(pkey=208, numeric_array=[]),
PostGresAllTypesRowData(pkey=209, jsonb_array=[]),
# non-empty array values, including nulls
PostGresAllTypesRowData(pkey=301, int_array=[123, 456, None]),
PostGresAllTypesRowData(pkey=302, bool_array=[True, False, None]),
PostGresAllTypesRowData(pkey=303, bytes_array=[BYTES_1, BYTES_2, None]),
PostGresAllTypesRowData(pkey=304, date_array=[SOME_DATE, None]),
PostGresAllTypesRowData(pkey=305, float_array=[3.1415926, 2.71828, None]),
PostGresAllTypesRowData(pkey=306, string_array=["One", "Two", None]),
PostGresAllTypesRowData(pkey=307, timestamp_array=[SOME_TIME, NANO_TIME, None]),
PostGresAllTypesRowData(pkey=308, numeric_array=[NUMERIC_1, NUMERIC_2, None]),
PostGresAllTypesRowData(pkey=309, jsonb_array=[JSON_1, JSON_2, None]),
)

if _helpers.USE_EMULATOR:
Expand Down

0 comments on commit 43a3a39

Please sign in to comment.