Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit ad7bcdd
Merge: 74a8308 4c04457
Author: Chuck McAndrew <[email protected]>
Date:   Wed Feb 17 13:05:43 2021 -0500

    Merge pull request #167 from adhocteam/cm-204-add-file-queue

    Cm 204 add file queue components to backend app

commit 4c04457
Author: Chuck McAndrew <[email protected]>
Date:   Wed Feb 17 11:57:54 2021 -0500

    update handler.test.js and switch to auditLogger
  • Loading branch information
Chuck McAndrew committed Feb 17, 2021
1 parent c677217 commit 3b79b27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/routes/files/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import addToScanQueue from '../../services/queue';
import ActivityReportPolicy from '../../policies/activityReport';
import { activityReportById } from '../../services/activityReports';
import { userById } from '../../services/users';
import logger from '../../logger';
import { auditLogger } from '../../logger';

const fileType = require('file-type');
const multiparty = require('multiparty');
Expand Down Expand Up @@ -139,7 +139,7 @@ export default async function uploadHandler(req, res) {
} catch (err) {
if (metadata) {
await updateStatus(metadata.id, fileStatuses.queueingFailed);
logger.error(`${logContext} Failed to queue ${metadata.originalFileName}. Error: ${err}`);
auditLogger.error(`${logContext} Failed to queue ${metadata.originalFileName}. Error: ${err}`);
}
}
});
Expand Down
7 changes: 3 additions & 4 deletions src/routes/files/handlers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import db, {
} from '../../models';
import app from '../../app';
import s3Uploader from '../../lib/s3Uploader';
// disable this to allow mocking this function
// eslint-disable-next-line no-unused-vars
import addToScanQueue from '../../services/queue';
import * as queue from '../../services/queue';
import SCOPES from '../../middleware/scopeConstants';
import { REPORT_STATUSES } from '../../constants';
import ActivityReportPolicy from '../../policies/activityReport';
Expand All @@ -21,7 +19,6 @@ const request = require('supertest');
const ORIGINAL_ENV = process.env;

jest.mock('../../lib/s3Uploader');
jest.mock('../../services/queue');

const mockUser = {
id: 100,
Expand All @@ -47,6 +44,7 @@ const mockUser = {

const mockSession = jest.fn();
mockSession.userId = mockUser.id;
const mockAddToScanQueue = jest.spyOn(queue, 'default').mockImplementation(() => jest.fn());

const reportObject = {
activityRecipientType: 'grantee',
Expand Down Expand Up @@ -97,6 +95,7 @@ describe('File Upload', () => {
fileId = res.body.id;
expect(s3Uploader).toHaveBeenCalled();
});
expect(mockAddToScanQueue).toHaveBeenCalled();
});
it('checks the metadata was uploaded to the database', async () => {
ActivityReportPolicy.mockImplementation(() => ({
Expand Down

0 comments on commit 3b79b27

Please sign in to comment.