-
-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add tests to JSON parsers (#2720)
- Loading branch information
1 parent
9820fe5
commit b5df699
Showing
3 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { test, describe, assert } from 'poku'; | ||
import { createRequire } from 'node:module'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const { | ||
createConnection, | ||
describeOptions, | ||
} = require('../../../common.test.cjs'); | ||
|
||
describe('JSON Parser', describeOptions); | ||
|
||
const connection = createConnection().promise(); | ||
|
||
Promise.all([ | ||
test(async () => { | ||
const [result] = await connection.query( | ||
`SELECT CAST('{"test": true}' AS JSON) AS json_result`, | ||
); | ||
|
||
assert.deepStrictEqual( | ||
result[0].json_result, | ||
{ test: true }, | ||
'Ensure JSON return parsed (query)', | ||
); | ||
}), | ||
test(async () => { | ||
const [result] = await connection.execute( | ||
`SELECT CAST('{"test": true}' AS JSON) AS json_result`, | ||
); | ||
|
||
assert.deepStrictEqual( | ||
result[0].json_result, | ||
{ test: true }, | ||
'Ensure JSON return parsed (execute)', | ||
); | ||
}), | ||
]).then(async () => { | ||
await connection.end(); | ||
}); |
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,41 @@ | ||
import { test, describe, assert } from 'poku'; | ||
import { createRequire } from 'node:module'; | ||
|
||
const require = createRequire(import.meta.url); | ||
const { | ||
createConnection, | ||
describeOptions, | ||
} = require('../../../common.test.cjs'); | ||
|
||
describe('JSON String', describeOptions); | ||
|
||
const connection = createConnection({ | ||
jsonStrings: true, | ||
}).promise(); | ||
|
||
Promise.all([ | ||
test(async () => { | ||
const [result] = await connection.query( | ||
`SELECT CAST('{"test": true}' AS JSON) AS json_result`, | ||
); | ||
|
||
assert.deepStrictEqual( | ||
result[0].json_result, | ||
'{"test": true}', | ||
'Ensure JSON return as string (query)', | ||
); | ||
}), | ||
test(async () => { | ||
const [result] = await connection.execute( | ||
`SELECT CAST('{"test": true}' AS JSON) AS json_result`, | ||
); | ||
|
||
assert.deepStrictEqual( | ||
result[0].json_result, | ||
'{"test": true}', | ||
'Ensure JSON return as string (execute)', | ||
); | ||
}), | ||
]).then(async () => { | ||
await connection.end(); | ||
}); |