-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #121
- Loading branch information
Showing
4 changed files
with
39 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
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 |
---|---|---|
|
@@ -338,6 +338,30 @@ describe('test/client.test.ts', () => { | |
}); | ||
}); | ||
|
||
describe('logging', () => { | ||
const mockLogs: string[] = []; | ||
|
||
it('should logging sql', async () => { | ||
const db = new RDSClient({ | ||
...config, | ||
logging: (sql, { threadId }) => { | ||
assert(typeof threadId === 'number'); | ||
mockLogs.push(sql); | ||
}, | ||
}); | ||
|
||
await db.query('show tables'); | ||
assert.deepEqual(mockLogs, [ 'show tables' ]); | ||
// logging SQL string with variable replaced | ||
await db.query('select * from ?? where email = ? limit 1', | ||
[ table, prefix + '[email protected]' ]); | ||
assert.deepEqual(mockLogs, [ | ||
'show tables', | ||
`select * from \`${table}\` where email = '${prefix + '[email protected]'}' limit 1`, | ||
]); | ||
}); | ||
}); | ||
|
||
describe('beginTransactionScope(scope)', () => { | ||
it('should beginTransactionScope() error', async () => { | ||
const failDB = new RDSClient({ | ||
|