Skip to content

Commit

Permalink
feat: remove codeql
Browse files Browse the repository at this point in the history
  • Loading branch information
alinarublea committed Oct 26, 2023
1 parent 0360407 commit a506edf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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`);
}

/**
Expand Down
21 changes: 18 additions & 3 deletions test/db.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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,
Expand All @@ -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 () => {
Expand Down

0 comments on commit a506edf

Please sign in to comment.