-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32b98f1
commit c6c85b0
Showing
5 changed files
with
71 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
// Test functions client | ||
// invoke | ||
|
||
import { CHINOOK_API_KEY, CHINOOK_DATABASE_URL } from "../../../test/shared" | ||
import { FunctionsClient } from "../_functions/FunctionsClient" | ||
|
||
const TEST_SQL_FUNCTION_ID = 'test-1-sql' | ||
const TEST_JS_FUNCTION_ID = 'test-1-js' | ||
|
||
const TEST_FUNCTION_ARG = { | ||
filter: 'a', | ||
limit: 10 | ||
} | ||
|
||
const functions = new FunctionsClient(CHINOOK_DATABASE_URL) | ||
|
||
describe('FunctionsClient', () => { | ||
it('should invoke a JS function', async () => { | ||
|
||
const { data, error } = await functions.invoke(TEST_JS_FUNCTION_ID, { | ||
params: TEST_FUNCTION_ARG, | ||
headers: { | ||
'Authorization': `Bearer ${CHINOOK_API_KEY}` | ||
} | ||
}) | ||
expect(data.message).toBeDefined() | ||
expect(data.result).toBeDefined() | ||
expect(error).toBeNull() | ||
}) | ||
|
||
it('should invoke a SQL function', async () => { | ||
const { data, error } = await functions.invoke(TEST_SQL_FUNCTION_ID, { | ||
params: TEST_FUNCTION_ARG, | ||
headers: { | ||
'Authorization': `Bearer ${CHINOOK_API_KEY}` | ||
} | ||
}) | ||
expect(data).toBeDefined() | ||
expect(data.length > 0).toBeTruthy() | ||
expect(error).toBeNull() | ||
}) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters