mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-21 07:28:26 +03:00
server: Add tests for the event trigger big int and geojson format payload bug fix
GitOrigin-RevId: 1e796b16dca54849334381e855b17b19609c8b7a
This commit is contained in:
parent
5238bb8011
commit
44f6f06e89
@ -0,0 +1,57 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE EXTENSION IF NOT EXISTS postgis;
|
||||
|
||||
create table hge_tests.test_bigint(
|
||||
id bigint,
|
||||
name text
|
||||
);
|
||||
|
||||
create table hge_tests.test_geojson(
|
||||
id SERIAL PRIMARY KEY,
|
||||
location GEOGRAPHY(Point)
|
||||
);
|
||||
|
||||
INSERT INTO hge_tests.test_geojson (location) VALUES ('POINT(-43.77 45.64)');
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: test_bigint
|
||||
|
||||
- type: track_table
|
||||
args:
|
||||
schema: hge_tests
|
||||
name: test_geojson
|
||||
|
||||
- type: create_event_trigger
|
||||
args:
|
||||
name: bigint_all
|
||||
table:
|
||||
schema: hge_tests
|
||||
name: test_bigint
|
||||
insert:
|
||||
columns: '*'
|
||||
update:
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
||||
|
||||
- type: create_event_trigger
|
||||
args:
|
||||
name: geojson_all
|
||||
table:
|
||||
schema: hge_tests
|
||||
name: test_geojson
|
||||
insert:
|
||||
columns: '*'
|
||||
update:
|
||||
columns: '*'
|
||||
delete:
|
||||
columns: '*'
|
||||
webhook: http://127.0.0.1:5592
|
@ -0,0 +1,16 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: delete_event_trigger
|
||||
args:
|
||||
name: bigint_all
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table hge_tests.test_bigint;
|
||||
- type: delete_event_trigger
|
||||
args:
|
||||
name: geojson_all
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table hge_tests.test_geojson;
|
@ -155,6 +155,69 @@ class TestEventFlood(object):
|
||||
ns.sort()
|
||||
assert ns == list(payload)
|
||||
|
||||
@usefixtures("per_class_tests_db_state")
|
||||
class TestEventDataFormat(object):
|
||||
|
||||
@classmethod
|
||||
def dir(cls):
|
||||
return 'queries/event_triggers/data_format'
|
||||
|
||||
def test_bigint(self, hge_ctx, evts_webhook):
|
||||
table = {"schema": "hge_tests", "name": "test_bigint"}
|
||||
|
||||
init_row = {"id": 50755254975729665, "name": "hello"}
|
||||
exp_ev_data = {
|
||||
"old": None,
|
||||
"new": {"id": "50755254975729665", "name": "hello"}
|
||||
}
|
||||
st_code, resp = insert(hge_ctx, table, init_row)
|
||||
assert st_code == 200, resp
|
||||
check_event(hge_ctx, evts_webhook, "bigint_all", table, "INSERT", exp_ev_data)
|
||||
|
||||
def test_geojson(self, hge_ctx, evts_webhook):
|
||||
table = {"schema": "hge_tests", "name": "test_geojson"}
|
||||
|
||||
exp_ev_data = {
|
||||
"old": { "id" : 1,
|
||||
"location":{
|
||||
"coordinates":[
|
||||
-43.77,
|
||||
45.64
|
||||
],
|
||||
"crs":{
|
||||
"type":"name",
|
||||
"properties":{
|
||||
"name":"urn:ogc:def:crs:EPSG::4326"
|
||||
}
|
||||
},
|
||||
"type":"Point"
|
||||
}
|
||||
},
|
||||
"new": { "id": 2,
|
||||
"location":{
|
||||
"coordinates":[
|
||||
-43.77,
|
||||
45.64
|
||||
],
|
||||
"crs":{
|
||||
"type":"name",
|
||||
"properties":{
|
||||
"name":"urn:ogc:def:crs:EPSG::4326"
|
||||
}
|
||||
},
|
||||
"type":"Point"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
where_exp = {"id" : 1}
|
||||
set_exp = {"id": 2}
|
||||
st_code, resp = update(hge_ctx, table, where_exp, set_exp)
|
||||
assert st_code == 200, resp
|
||||
check_event(hge_ctx, evts_webhook, "geojson_all", table, "UPDATE", exp_ev_data)
|
||||
|
||||
|
||||
|
||||
@usefixtures("per_class_tests_db_state")
|
||||
class TestCreateEvtQuery(object):
|
||||
|
Loading…
Reference in New Issue
Block a user