From a506edf0fc230f2721c10e36af7b693d2ac46fb8 Mon Sep 17 00:00:00 2001 From: alinarublea Date: Thu, 26 Oct 2023 14:22:48 +0200 Subject: [PATCH] feat: remove codeql --- src/db.js | 3 ++- test/db.test.js | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/db.js b/src/db.js index 979505c6..9d4a9290 100644 --- a/src/db.js +++ b/src/db.js @@ -82,7 +82,7 @@ export default class DB { ], }; await this.saveRecord(newAudit, TABLE_AUDITS); - this.log.info(`Audit for domain ${site.domain} saved successfully`); + this.log.info(`Saving successful audit for domain ${site.domain} saved successfully`); return Promise.resolve(newAudit); } @@ -100,6 +100,7 @@ export default class DB { scores: {}, }; await this.saveRecord(newAudit, TABLE_AUDITS); + this.log.info(`Saving error audit for domain ${site.domain} saved successfully`); } /** diff --git a/test/db.test.js b/test/db.test.js index 5ae74a2b..bf3820b8 100644 --- a/test/db.test.js +++ b/test/db.test.js @@ -24,7 +24,7 @@ describe('DB Tests', () => { let mockContext; let logInfo = ''; let logError = ''; - let testSite = { domain: 'www.testdomain.com', path: '/testpath' }; + const testSite = { domain: 'www.testdomain.com', path: '/testpath' }; beforeEach(() => { mockContext = { @@ -49,7 +49,7 @@ describe('DB Tests', () => { assert.strictEqual(db.log, mockContext.log); }); - it('should save the record to dynamodb and log success', async () => { + it('should save the successful audit to dynamodb and log success', async () => { const DBDocMock = await esmock('../src/db.js', { '@aws-sdk/lib-dynamodb': { DynamoDBDocumentClient: DBDocClientMock, @@ -76,7 +76,22 @@ describe('DB Tests', () => { }, }, }); - assert.strictEqual(logInfo, 'Audit for domain www.testdomain.com saved successfully'); + assert.strictEqual(logInfo, 'Saving successful audit for domain www.testdomain.com saved successfully'); + }); + + it('should save the error audit to dynamodb and log success', async () => { + const DBDocMock = await esmock('../src/db.js', { + '@aws-sdk/lib-dynamodb': { + DynamoDBDocumentClient: DBDocClientMock, + }, + }); + const db = new DBDocMock(mockContext); + await db.saveAuditError(testSite, { + error: { + message: 'Could not run audit for www.testdomain.com', + }, + }); + assert.strictEqual(logInfo, 'Saving error audit for domain www.testdomain.com saved successfully'); }); it('should get the site from dynamodb', async () => {