From c0913654bf93f27f69c28eca0db452eb52fef1d8 Mon Sep 17 00:00:00 2001 From: David Hasani Date: Tue, 10 Dec 2024 10:13:06 -0800 Subject: [PATCH 1/3] refactor(amazonq): remove duplicate code block in test file --- .../commands/transformByQ.test.ts | 176 +++++------------- 1 file changed, 47 insertions(+), 129 deletions(-) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index b6ff86a94cd..e4af23dc02e 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -46,6 +46,48 @@ import { convertDateToTimestamp, convertToTimeString } from '../../../shared/dat describe('transformByQ', function () { let tempDir: string + let validSctFile = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ` beforeEach(async function () { tempDir = (await TestFolder.create()).path @@ -401,49 +443,7 @@ describe('transformByQ', function () { }) it(`WHEN validateMetadataFile on fully valid .sct file THEN passes validation`, async function () { - const sampleFileContents = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ` - const isValidMetadata = await validateSQLMetadataFile(sampleFileContents, { tabID: 'abc123' }) + const isValidMetadata = await validateSQLMetadataFile(validSctFile, { tabID: 'abc123' }) assert.strictEqual(isValidMetadata, true) assert.strictEqual(transformByQState.getSourceDB(), DB.ORACLE) assert.strictEqual(transformByQState.getTargetDB(), DB.AURORA_POSTGRESQL) @@ -455,96 +455,14 @@ describe('transformByQ', function () { }) it(`WHEN validateMetadataFile on .sct file with unsupported source DB THEN fails validation`, async function () { - const sampleFileContents = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ` - const isValidMetadata = await validateSQLMetadataFile(sampleFileContents, { tabID: 'abc123' }) + const sctFileWithInvalidSource = validSctFile.replace('oracle', 'not-oracle') + const isValidMetadata = await validateSQLMetadataFile(sctFileWithInvalidSource, { tabID: 'abc123' }) assert.strictEqual(isValidMetadata, false) }) it(`WHEN validateMetadataFile on .sct file with unsupported target DB THEN fails validation`, async function () { - const sampleFileContents = ` - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ` - const isValidMetadata = await validateSQLMetadataFile(sampleFileContents, { tabID: 'abc123' }) + const sctFileWithInvalidTarget = validSctFile.replace('postgresql', 'not-postgresql') + const isValidMetadata = await validateSQLMetadataFile(sctFileWithInvalidTarget, { tabID: 'abc123' }) assert.strictEqual(isValidMetadata, false) }) }) From 958dd204e6f6e4c149482a846ce8e5fcf41b0e71 Mon Sep 17 00:00:00 2001 From: David Hasani Date: Tue, 10 Dec 2024 10:15:15 -0800 Subject: [PATCH 2/3] small rename --- .../core/src/test/codewhisperer/commands/transformByQ.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index e4af23dc02e..ba4a54d7081 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -461,7 +461,7 @@ describe('transformByQ', function () { }) it(`WHEN validateMetadataFile on .sct file with unsupported target DB THEN fails validation`, async function () { - const sctFileWithInvalidTarget = validSctFile.replace('postgresql', 'not-postgresql') + const sctFileWithInvalidTarget = validSctFile.replace('aurora_postgresql', 'not-postgresql') const isValidMetadata = await validateSQLMetadataFile(sctFileWithInvalidTarget, { tabID: 'abc123' }) assert.strictEqual(isValidMetadata, false) }) From 66f1d74bd08215c9e79d68b8c30e9d812a784744 Mon Sep 17 00:00:00 2001 From: David Hasani Date: Tue, 10 Dec 2024 12:11:30 -0800 Subject: [PATCH 3/3] fix lint error --- .../core/src/test/codewhisperer/commands/transformByQ.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts index ba4a54d7081..0b09800337c 100644 --- a/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts +++ b/packages/core/src/test/codewhisperer/commands/transformByQ.test.ts @@ -46,7 +46,7 @@ import { convertDateToTimestamp, convertToTimeString } from '../../../shared/dat describe('transformByQ', function () { let tempDir: string - let validSctFile = ` + const validSctFile = `