@@ -170,6 +170,9 @@ describe('/functions', () => {
170
170
await axios . post ( `${ URL } /query` , {
171
171
query : `DROP FUNCTION IF EXISTS "${ func . name } ";` ,
172
172
} )
173
+ await axios . post ( `${ URL } /query` , {
174
+ query : `CREATE SCHEMA IF NOT EXISTS test_schema;` ,
175
+ } )
173
176
} )
174
177
it ( 'GET' , async ( ) => {
175
178
const res = await axios . get ( `${ URL } /functions` )
@@ -210,14 +213,14 @@ describe('/functions', () => {
210
213
const updates = {
211
214
name : 'test_func_renamed' ,
212
215
params : [ 'integer' , 'integer' ] ,
213
- // schema: 'test_schema' // TODO: test patching function schema
216
+ schema : 'test_schema' ,
214
217
// extension: 'mathlib', // TODO: test patching function extension
215
218
}
216
219
217
220
let { data : updated } = await axios . patch ( `${ URL } /functions/${ func . id } ` , updates )
218
221
assert . equal ( updated . id , func . id )
219
222
assert . equal ( updated . name , 'test_func_renamed' )
220
- // assert.equal(updated.schema, 'test_schema')
223
+ assert . equal ( updated . schema , 'test_schema' )
221
224
} )
222
225
it ( 'DELETE' , async ( ) => {
223
226
await axios . delete ( `${ URL } /functions/${ func . id } ` )
@@ -309,7 +312,9 @@ describe('/tables', async () => {
309
312
assert . equal ( true , ! ! included )
310
313
} )
311
314
it ( 'GET enum /columns with quoted name' , async ( ) => {
312
- await axios . post ( `${ URL } /query` , { query : 'CREATE TYPE "T" AS ENUM (\'v\'); CREATE TABLE t ( c "T" );' } )
315
+ await axios . post ( `${ URL } /query` , {
316
+ query : 'CREATE TYPE "T" AS ENUM (\'v\'); CREATE TABLE t ( c "T" );' ,
317
+ } )
313
318
const { data : columns } = await axios . get ( `${ URL } /columns` )
314
319
const column = columns . find ( ( x ) => x . table == 't' )
315
320
await axios . post ( `${ URL } /query` , { query : 'DROP TABLE t; DROP TYPE "T";' } )
@@ -875,18 +880,21 @@ describe('/publications FOR ALL TABLES', () => {
875
880
describe ( '/triggers' , ( ) => {
876
881
const renamedTriggerName = 'test_trigger_renamed'
877
882
const trigger = {
878
- name : 'test_trigger' ,
879
- schema : 'public' ,
880
- table : 'users_audit' ,
881
- function_schema : 'public' ,
882
- function_name : 'audit_action' ,
883
- function_args : [ 'test1' , 'test2' ] ,
884
- activation : 'AFTER' ,
885
- events : [ 'UPDATE' ] ,
886
- orientation : 'ROW' ,
887
- condition : '(old.* IS DISTINCT FROM new.*)' ,
883
+ name : 'test_trigger' ,
884
+ schema : 'public' ,
885
+ table : 'users_audit' ,
886
+ function_schema : 'public' ,
887
+ function_name : 'audit_action' ,
888
+ function_args : [ 'test1' , 'test2' ] ,
889
+ activation : 'AFTER' ,
890
+ events : [ 'UPDATE' ] ,
891
+ orientation : 'ROW' ,
892
+ condition : '(old.* IS DISTINCT FROM new.*)' ,
893
+ }
894
+ const multiEventTrigger = {
895
+ ...trigger ,
896
+ ...{ name : 'test_multi_event_trigger' , events : [ 'insert' , 'update' , 'delete' ] , condition : '' } ,
888
897
}
889
- const multiEventTrigger = { ...trigger , ...{ name : 'test_multi_event_trigger' , events : [ 'insert' , 'update' , 'delete' ] , condition : '' } }
890
898
891
899
before ( async ( ) => {
892
900
await axios . post ( `${ URL } /query` , {
@@ -946,10 +954,14 @@ describe('/triggers', () => {
946
954
947
955
const sortedTriggerData = triggerData . sort ( ( a , b ) => a . name . length - b . name . length )
948
956
949
- const { data : singleEventTriggerRecord } = await axios . get ( `${ URL } /triggers/${ sortedTriggerData [ 0 ] . id } ` )
957
+ const { data : singleEventTriggerRecord } = await axios . get (
958
+ `${ URL } /triggers/${ sortedTriggerData [ 0 ] . id } `
959
+ )
950
960
assert . strictEqual ( singleEventTriggerRecord . name , 'test_trigger' )
951
961
952
- const { data : multiEventTriggerRecord } = await axios . get ( `${ URL } /triggers/${ sortedTriggerData [ 1 ] . id } ` )
962
+ const { data : multiEventTriggerRecord } = await axios . get (
963
+ `${ URL } /triggers/${ sortedTriggerData [ 1 ] . id } `
964
+ )
953
965
assert . strictEqual ( multiEventTriggerRecord . name , 'test_multi_event_trigger' )
954
966
} )
955
967
@@ -962,14 +974,14 @@ describe('/triggers', () => {
962
974
963
975
const { data : updatedTriggerRecord } = await axios . patch ( `${ URL } /triggers/${ id } ` , {
964
976
name : 'test_trigger_renamed' ,
965
- enabled_mode : 'DISABLED'
977
+ enabled_mode : 'DISABLED' ,
966
978
} )
967
979
968
980
assert . strictEqual ( updatedTriggerRecord . name , 'test_trigger_renamed' )
969
981
assert . strictEqual ( updatedTriggerRecord . enabled_mode , 'DISABLED' )
970
982
971
983
const { data : reEnabledTriggerRecord } = await axios . patch ( `${ URL } /triggers/${ id } ` , {
972
- enabled_mode : 'REPLICA'
984
+ enabled_mode : 'REPLICA' ,
973
985
} )
974
986
975
987
assert . strictEqual ( reEnabledTriggerRecord . enabled_mode , 'REPLICA' )
0 commit comments