@@ -61,32 +61,27 @@ 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 ( "CREATE OR REPLACE FUNCTION public.test_function()" ) ,
70
+ config_params : null ,
71
+ definition : "BEGIN RETURN 42; END;" ,
72
+ id : expect . any ( Number ) ,
73
+ identity_argument_types : "" ,
74
+ is_set_returning_function : false ,
75
+ language : "plpgsql" ,
76
+ name : "test_function" ,
77
+ return_type : "integer" ,
78
+ return_type_id : 23 ,
79
+ return_type_relation_id : null ,
80
+ schema : "public" ,
81
+ security_definer : false ,
82
+ } )
88
83
89
- const { id } = response . json ( )
84
+ const { id } = responseData
90
85
91
86
const retrieveResponse = await app . inject ( {
92
87
method : 'GET' ,
@@ -96,30 +91,25 @@ describe('server/routes/functions', () => {
96
91
} ,
97
92
} )
98
93
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
- ` )
94
+ const retrieveData = retrieveResponse . json ( )
95
+ expect ( retrieveData ) . toMatchObject ( {
96
+ args : [ ] ,
97
+ argument_types : "" ,
98
+ behavior : "VOLATILE" ,
99
+ complete_statement : expect . stringContaining ( "CREATE OR REPLACE FUNCTION public.test_function()" ) ,
100
+ config_params : null ,
101
+ definition : "BEGIN RETURN 42; END;" ,
102
+ id : expect . any ( Number ) ,
103
+ identity_argument_types : "" ,
104
+ is_set_returning_function : false ,
105
+ language : "plpgsql" ,
106
+ name : "test_function" ,
107
+ return_type : "integer" ,
108
+ return_type_id : 23 ,
109
+ return_type_relation_id : null ,
110
+ schema : "public" ,
111
+ security_definer : false ,
112
+ } )
123
113
124
114
const updateResponse = await app . inject ( {
125
115
method : 'PATCH' ,
@@ -136,30 +126,25 @@ describe('server/routes/functions', () => {
136
126
} ,
137
127
} )
138
128
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
- ` )
129
+ const updateData = updateResponse . json ( )
130
+ expect ( updateData ) . toMatchObject ( {
131
+ args : [ ] ,
132
+ argument_types : "" ,
133
+ behavior : "VOLATILE" ,
134
+ complete_statement : expect . stringContaining ( "CREATE OR REPLACE FUNCTION public.test_function()" ) ,
135
+ config_params : null ,
136
+ definition : "BEGIN RETURN 50; END;" ,
137
+ id : expect . any ( Number ) ,
138
+ identity_argument_types : "" ,
139
+ is_set_returning_function : false ,
140
+ language : "plpgsql" ,
141
+ name : "test_function" ,
142
+ return_type : "integer" ,
143
+ return_type_id : 23 ,
144
+ return_type_relation_id : null ,
145
+ schema : "public" ,
146
+ security_definer : false ,
147
+ } )
163
148
164
149
const deleteResponse = await app . inject ( {
165
150
method : 'DELETE' ,
@@ -169,30 +154,25 @@ describe('server/routes/functions', () => {
169
154
} ,
170
155
} )
171
156
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
- ` )
157
+ const deleteData = deleteResponse . json ( )
158
+ expect ( deleteData ) . toMatchObject ( {
159
+ args : [ ] ,
160
+ argument_types : "" ,
161
+ behavior : "VOLATILE" ,
162
+ complete_statement : expect . stringContaining ( "CREATE OR REPLACE FUNCTION public.test_function()" ) ,
163
+ config_params : null ,
164
+ definition : "BEGIN RETURN 50; END;" ,
165
+ id : expect . any ( Number ) ,
166
+ identity_argument_types : "" ,
167
+ is_set_returning_function : false ,
168
+ language : "plpgsql" ,
169
+ name : "test_function" ,
170
+ return_type : "integer" ,
171
+ return_type_id : 23 ,
172
+ return_type_relation_id : null ,
173
+ schema : "public" ,
174
+ security_definer : false ,
175
+ } )
196
176
} )
197
177
198
178
test ( 'should return 400 for invalid payload' , async ( ) => {
0 commit comments