From 5d2d31ddec9be19cf5575e5d0f6569c1b10c8907 Mon Sep 17 00:00:00 2001 From: Sumit Suthar Date: Fri, 20 Sep 2024 16:30:31 +0530 Subject: [PATCH] Revert "chore: Removed noisy test log (#2583)" This reverts commit dc9cd2c2a38acc21c4fd5970d18db52225971e1c. --- test/unit/util/obfuscate-sql.test.js | 39 ++++++++++++++++------------ 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/test/unit/util/obfuscate-sql.test.js b/test/unit/util/obfuscate-sql.test.js index 8917190e05..c2942e1bd6 100644 --- a/test/unit/util/obfuscate-sql.test.js +++ b/test/unit/util/obfuscate-sql.test.js @@ -10,6 +10,7 @@ const tests = require('../../lib/cross_agent_tests/sql_obfuscation/sql_obfuscati const obfuscate = require('../../../lib/util/sql/obfuscate') function runTest(t, testCase, dialect) { + t.diagnostic(dialect) const obfuscated = obfuscate(testCase.sql, dialect) if (testCase.obfuscated.length === 1) { assert.equal(obfuscated, testCase.obfuscated[0]) @@ -18,24 +19,28 @@ function runTest(t, testCase, dialect) { } } -for (const testCase of tests) { - for (const dialect of testCase.dialects) { - test(`${dialect}: ${testCase.name}`, (t) => { - runTest(t, testCase, dialect) +test('sql obfuscation', async (t) => { + await Promise.all( + tests.map(async (tc) => { + await t.test(tc.name, (t) => { + for (let i = 0; i < tc.dialects.length; ++i) { + runTest(t, tc, tc.dialects[i]) + } + }) }) - } -} + ) -test('should handle line endings', () => { - const result = obfuscate('select * from foo where --abc\r\nbar=5', 'mysql') - assert.equal(result, 'select * from foo where ?\r\nbar=?') -}) + await t.test('should handle line endings', () => { + const result = obfuscate('select * from foo where --abc\r\nbar=5', 'mysql') + assert.equal(result, 'select * from foo where ?\r\nbar=?') + }) -test('should handle large JSON inserts', () => { - const JSONData = '{"data": "' + new Array(8400000).fill('a').join('') + '"}' - const result = obfuscate( - 'INSERT INTO "Documents" ("data") VALUES (\'' + JSONData + "')", - 'postgres' - ) - assert.equal(result, 'INSERT INTO "Documents" ("data") VALUES (?)') + await t.test('should handle large JSON inserts', () => { + const JSONData = '{"data": "' + new Array(8400000).fill('a').join('') + '"}' + const result = obfuscate( + 'INSERT INTO "Documents" ("data") VALUES (\'' + JSONData + "')", + 'postgres' + ) + assert.equal(result, 'INSERT INTO "Documents" ("data") VALUES (?)') + }) })