From e317338602514004f699f44f6909562516e84c01 Mon Sep 17 00:00:00 2001 From: Przemyslaw Motacki Date: Wed, 4 Oct 2023 13:55:10 +0200 Subject: [PATCH] SNOW-930831: Add randomization to the table name in put/get test --- test/integration/testPutGet.js | 3 ++- test/integration/testUtil.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/test/integration/testPutGet.js b/test/integration/testPutGet.js index 2e5ef67a0..5e8109c9e 100644 --- a/test/integration/testPutGet.js +++ b/test/integration/testPutGet.js @@ -12,10 +12,11 @@ const tmp = require('tmp'); const os = require('os'); const path = require('path'); const zlib = require('zlib'); +const {randomizeName} = require("./testUtil"); const DATABASE_NAME = connOption.valid.database; const SCHEMA_NAME = connOption.valid.schema; -const TEMP_TABLE_NAME = 'TEMP_TABLE'; +const TEMP_TABLE_NAME = randomizeName('TEMP_TABLE'); const SKIPPED = 'SKIPPED'; const UPLOADED = 'UPLOADED'; diff --git a/test/integration/testUtil.js b/test/integration/testUtil.js index ce9812077..a57131660 100644 --- a/test/integration/testUtil.js +++ b/test/integration/testUtil.js @@ -5,6 +5,7 @@ const snowflake = require('./../../lib/snowflake'); const connOptions = require('./connectionOptions'); const assert = require('assert'); const fs = require('fs'); +const crypto = require('crypto'); module.exports.createConnection = function (validConnectionOptionsOverride = {}) { return snowflake.createConnection({ @@ -244,3 +245,14 @@ module.exports.deleteFolderSyncIgnoringErrors = function (directory) { console.warn(`Cannot delete folder ${directory}: ${JSON.stringify(e)}`); } }; + +/** + * @param name string + */ +module.exports.randomizeName = function (name) { + if (name === null || name.trim() === '') { + throw new Error('Name must be non empty string'); + } + const randomString = crypto.randomBytes(4).toString('hex'); + return name.concat(randomString); +};