@@ -61,32 +61,29 @@ describe('server/routes/functions', () => {
61
61
} ,
62
62
} )
63
63
expect ( response . statusCode ) . toBe ( 200 )
64
- expect ( response . json ( ) ) . toMatchInlineSnapshot ( `
65
- {
66
- "args": [],
67
- "argument_types": "",
68
- "behavior": "VOLATILE",
69
- "complete_statement": "CREATE OR REPLACE FUNCTION public.test_function()
70
- RETURNS integer
71
- LANGUAGE plpgsql
72
- AS $function$BEGIN RETURN 42; END;$function$
73
- ",
74
- "config_params": null,
75
- "definition": "BEGIN RETURN 42; END;",
76
- "id": expect.any(Number),
77
- "identity_argument_types": "",
78
- "is_set_returning_function": false,
79
- "language": "plpgsql",
80
- "name": "test_function",
81
- "return_type": "integer",
82
- "return_type_id": 23,
83
- "return_type_relation_id": null,
84
- "schema": "public",
85
- "security_definer": false,
86
- }
87
- ` )
64
+ const responseData = response . json ( )
65
+ expect ( responseData ) . toMatchObject ( {
66
+ args : [ ] ,
67
+ argument_types : '' ,
68
+ behavior : 'VOLATILE' ,
69
+ complete_statement : expect . stringContaining (
70
+ 'CREATE OR REPLACE FUNCTION public.test_function()'
71
+ ) ,
72
+ config_params : null ,
73
+ definition : 'BEGIN RETURN 42; END;' ,
74
+ id : expect . any ( Number ) ,
75
+ identity_argument_types : '' ,
76
+ is_set_returning_function : false ,
77
+ language : 'plpgsql' ,
78
+ name : 'test_function' ,
79
+ return_type : 'integer' ,
80
+ return_type_id : 23 ,
81
+ return_type_relation_id : null ,
82
+ schema : 'public' ,
83
+ security_definer : false ,
84
+ } )
88
85
89
- const { id } = response . json ( )
86
+ const { id } = responseData
90
87
91
88
const retrieveResponse = await app . inject ( {
92
89
method : 'GET' ,
@@ -96,30 +93,27 @@ describe('server/routes/functions', () => {
96
93
} ,
97
94
} )
98
95
expect ( retrieveResponse . statusCode ) . toBe ( 200 )
99
- expect ( retrieveResponse . json ( ) ) . toMatchInlineSnapshot ( `
100
- {
101
- "args": [],
102
- "argument_types": "",
103
- "behavior": "VOLATILE",
104
- "complete_statement": "CREATE OR REPLACE FUNCTION public.test_function()
105
- RETURNS integer
106
- LANGUAGE plpgsql
107
- AS $function$BEGIN RETURN 42; END;$function$
108
- ",
109
- "config_params": null,
110
- "definition": "BEGIN RETURN 42; END;",
111
- "id": ${ id } ,
112
- "identity_argument_types": "",
113
- "is_set_returning_function": false,
114
- "language": "plpgsql",
115
- "name": "test_function",
116
- "return_type": "integer",
117
- "return_type_id": 23,
118
- "return_type_relation_id": null,
119
- "schema": "public",
120
- "security_definer": false,
121
- }
122
- ` )
96
+ const retrieveData = retrieveResponse . json ( )
97
+ expect ( retrieveData ) . toMatchObject ( {
98
+ args : [ ] ,
99
+ argument_types : '' ,
100
+ behavior : 'VOLATILE' ,
101
+ complete_statement : expect . stringContaining (
102
+ 'CREATE OR REPLACE FUNCTION public.test_function()'
103
+ ) ,
104
+ config_params : null ,
105
+ definition : 'BEGIN RETURN 42; END;' ,
106
+ id : expect . any ( Number ) ,
107
+ identity_argument_types : '' ,
108
+ is_set_returning_function : false ,
109
+ language : 'plpgsql' ,
110
+ name : 'test_function' ,
111
+ return_type : 'integer' ,
112
+ return_type_id : 23 ,
113
+ return_type_relation_id : null ,
114
+ schema : 'public' ,
115
+ security_definer : false ,
116
+ } )
123
117
124
118
const updateResponse = await app . inject ( {
125
119
method : 'PATCH' ,
@@ -136,30 +130,27 @@ describe('server/routes/functions', () => {
136
130
} ,
137
131
} )
138
132
expect ( updateResponse . statusCode ) . toBe ( 200 )
139
- expect ( updateResponse . json ( ) ) . toMatchInlineSnapshot ( `
140
- {
141
- "args": [],
142
- "argument_types": "",
143
- "behavior": "VOLATILE",
144
- "complete_statement": "CREATE OR REPLACE FUNCTION public.test_function()
145
- RETURNS integer
146
- LANGUAGE plpgsql
147
- AS $function$BEGIN RETURN 50; END;$function$
148
- ",
149
- "config_params": null,
150
- "definition": "BEGIN RETURN 50; END;",
151
- "id": ${ id } ,
152
- "identity_argument_types": "",
153
- "is_set_returning_function": false,
154
- "language": "plpgsql",
155
- "name": "test_function",
156
- "return_type": "integer",
157
- "return_type_id": 23,
158
- "return_type_relation_id": null,
159
- "schema": "public",
160
- "security_definer": false,
161
- }
162
- ` )
133
+ const updateData = updateResponse . json ( )
134
+ expect ( updateData ) . toMatchObject ( {
135
+ args : [ ] ,
136
+ argument_types : '' ,
137
+ behavior : 'VOLATILE' ,
138
+ complete_statement : expect . stringContaining (
139
+ 'CREATE OR REPLACE FUNCTION public.test_function()'
140
+ ) ,
141
+ config_params : null ,
142
+ definition : 'BEGIN RETURN 50; END;' ,
143
+ id : expect . any ( Number ) ,
144
+ identity_argument_types : '' ,
145
+ is_set_returning_function : false ,
146
+ language : 'plpgsql' ,
147
+ name : 'test_function' ,
148
+ return_type : 'integer' ,
149
+ return_type_id : 23 ,
150
+ return_type_relation_id : null ,
151
+ schema : 'public' ,
152
+ security_definer : false ,
153
+ } )
163
154
164
155
const deleteResponse = await app . inject ( {
165
156
method : 'DELETE' ,
@@ -169,30 +160,27 @@ describe('server/routes/functions', () => {
169
160
} ,
170
161
} )
171
162
expect ( deleteResponse . statusCode ) . toBe ( 200 )
172
- expect ( deleteResponse . json ( ) ) . toMatchInlineSnapshot ( `
173
- {
174
- "args": [],
175
- "argument_types": "",
176
- "behavior": "VOLATILE",
177
- "complete_statement": "CREATE OR REPLACE FUNCTION public.test_function()
178
- RETURNS integer
179
- LANGUAGE plpgsql
180
- AS $function$BEGIN RETURN 50; END;$function$
181
- ",
182
- "config_params": null,
183
- "definition": "BEGIN RETURN 50; END;",
184
- "id": ${ id } ,
185
- "identity_argument_types": "",
186
- "is_set_returning_function": false,
187
- "language": "plpgsql",
188
- "name": "test_function",
189
- "return_type": "integer",
190
- "return_type_id": 23,
191
- "return_type_relation_id": null,
192
- "schema": "public",
193
- "security_definer": false,
194
- }
195
- ` )
163
+ const deleteData = deleteResponse . json ( )
164
+ expect ( deleteData ) . toMatchObject ( {
165
+ args : [ ] ,
166
+ argument_types : '' ,
167
+ behavior : 'VOLATILE' ,
168
+ complete_statement : expect . stringContaining (
169
+ 'CREATE OR REPLACE FUNCTION public.test_function()'
170
+ ) ,
171
+ config_params : null ,
172
+ definition : 'BEGIN RETURN 50; END;' ,
173
+ id : expect . any ( Number ) ,
174
+ identity_argument_types : '' ,
175
+ is_set_returning_function : false ,
176
+ language : 'plpgsql' ,
177
+ name : 'test_function' ,
178
+ return_type : 'integer' ,
179
+ return_type_id : 23 ,
180
+ return_type_relation_id : null ,
181
+ schema : 'public' ,
182
+ security_definer : false ,
183
+ } )
196
184
} )
197
185
198
186
test ( 'should return 400 for invalid payload' , async ( ) => {
0 commit comments