Skip to content

Commit 626efbc

Browse files
committed
test(functions): add tests for retrival argument based
1 parent f8434be commit 626efbc

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/lib/functions.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,52 @@ test('retrieve set-returning function', async () => {
354354
`
355355
)
356356
})
357+
358+
test('retrieve function by args filter - polymorphic function with text argument', async () => {
359+
const res = await pgMeta.functions.retrieve({
360+
schema: 'public',
361+
name: 'polymorphic_function',
362+
args: ['text'],
363+
})
364+
expect(res.data).toMatchObject({
365+
name: 'polymorphic_function',
366+
schema: 'public',
367+
argument_types: 'text',
368+
args: [
369+
{ type_id: 25, mode: 'in' }, // text type_id is 25
370+
],
371+
})
372+
expect(res.error).toBeNull()
373+
})
374+
375+
test('retrieve function by args filter - polymorphic function with boolean argument', async () => {
376+
const res = await pgMeta.functions.retrieve({
377+
schema: 'public',
378+
name: 'polymorphic_function',
379+
args: ['boolean'],
380+
})
381+
expect(res.data).toMatchObject({
382+
name: 'polymorphic_function',
383+
schema: 'public',
384+
argument_types: 'boolean',
385+
args: [
386+
{ type_id: 16, mode: 'in' }, // boolean type_id is 16
387+
],
388+
})
389+
expect(res.error).toBeNull()
390+
})
391+
392+
test('retrieve function by args filter - function with no arguments', async () => {
393+
const res = await pgMeta.functions.retrieve({
394+
schema: 'public',
395+
name: 'function_returning_set_of_rows',
396+
args: [],
397+
})
398+
expect(res.data).toMatchObject({
399+
name: 'function_returning_set_of_rows',
400+
schema: 'public',
401+
argument_types: '',
402+
args: [],
403+
})
404+
expect(res.error).toBeNull()
405+
})

0 commit comments

Comments
 (0)