Skip to content

Commit

Permalink
BRS-1263 fiscal year end change (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronpettit authored Aug 15, 2023
1 parent 1cd558e commit 335951e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
44 changes: 43 additions & 1 deletion __tests__/export-variance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe("Export Variance Report", () => {
expect(response.statusCode).toBe(403);
});

test("Handler - 200 GET, with no jobs", async () => {
test("Handler - 400 no fiscal year provided", async () => {
const dateField = "dateGenerated"
const event = {
headers: {
Expand All @@ -126,6 +126,45 @@ describe("Export Variance Report", () => {
} catch (e) {
body = 'fail'
}
expect(result).toEqual(
expect.objectContaining({
headers: {
"Access-Control-Allow-Headers":
"Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token",
"Access-Control-Allow-Methods": "OPTIONS,GET,POST",
"Access-Control-Allow-Origin": "*",
"Content-Type": "application/json",
},
statusCode: 400,
}),
);
})

test("Handler - 200 GET, with no jobs", async () => {
const dateField = "dateGenerated"
const event = {
headers: {
Authorization: "Bearer " + token,
},
httpMethod: "GET",
queryStringParameters: {
getJob: "true",
fiscalYearEnd: 2023
},
};

jest.mock('../lambda/permissionUtil', () => {
return mockedSysadmin;
});
const varianceExportGET = require("../lambda/export-variance/GET/index");
const result = await varianceExportGET.handler(event, null);
let body;
try {
body = JSON.parse(result.body)
console.log('body:', body);
} catch (e) {
body = 'fail'
}
expect(result).toEqual(
expect.objectContaining({
headers: {
Expand All @@ -147,6 +186,9 @@ describe("Export Variance Report", () => {
Authorization: "Bearer " + token,
},
httpMethod: "GET",
queryStringParameters: {
fiscalYearEnd: 2023
},
};
jest.mock('../lambda/permissionUtil', () => {
return mockedSysadmin;
Expand Down
4 changes: 2 additions & 2 deletions __tests__/global/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,11 @@
"dateGenerated": "2023-01-05T22:12:49.314Z",
"lastSuccessfulJob": {
"dateGenerated": "2023-01-05T22:12:49.314Z",
"key": "dad2b66eca14331cb6186d181c51d08a/A&R_Variance_Report.csv"
"key": "f36c75c5d08d41effd2ccc8fd077c6ab/A&R_Variance_Report.csv"
},
"progressDescription": "Job Complete.",
"progressState": "complete",
"sk": "dad2b66eca14331cb6186d181c51d08a",
"sk": "f36c75c5d08d41effd2ccc8fd077c6ab",
"pk": "variance-exp-job",
"progressPercentage": 100
}
Expand Down
5 changes: 5 additions & 0 deletions lambda/export-variance/GET/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ exports.handler = async (event, context) => {
let params = event?.queryStringParameters || {};
params['roles'] = permissionObject.roles;

// Must provide fiscal year end
if (!params?.fiscalYearEnd) {
return sendResponse(400, { msg: "No fiscal year end provided." }, context);
}

// generate a job id from params+role
let hashParams = {...params};
delete hashParams.getJob;
Expand Down

0 comments on commit 335951e

Please sign in to comment.