Skip to content

Commit c5c1ca0

Browse files
committed
Post-rebase fixes
1 parent 4005e26 commit c5c1ca0

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

lambdas/api-handler/src/config/__tests__/env.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ describe('lambdaEnv', () => {
3838
process.env.SUPPLIER_ID_HEADER = 'nhsd-supplier-id';
3939
process.env.APIM_CORRELATION_HEADER = 'nhsd-correlation-id';
4040
process.env.LETTERS_TABLE_NAME = undefined; // simulate missing var
41-
process.env.MI_TABLE_NAME = 'mi-table'; process.env.LETTER_TTL_HOURS = '12960';
41+
process.env.MI_TABLE_NAME = 'mi-table';
42+
process.env.LETTER_TTL_HOURS = '12960';
4243
process.env.DOWNLOAD_URL_TTL_SECONDS = '60';
4344

4445
expect(() => require('../env')).toThrow(ZodError);
@@ -48,6 +49,7 @@ describe('lambdaEnv', () => {
4849
process.env.SUPPLIER_ID_HEADER = 'nhsd-supplier-id';
4950
process.env.APIM_CORRELATION_HEADER = 'nhsd-correlation-id';
5051
process.env.LETTERS_TABLE_NAME = 'letters-table';
52+
process.env.MI_TABLE_NAME = 'mi-table';
5153
process.env.LETTER_TTL_HOURS = '12960';
5254
process.env.DOWNLOAD_URL_TTL_SECONDS = '60';
5355

@@ -57,6 +59,7 @@ describe('lambdaEnv', () => {
5759
SUPPLIER_ID_HEADER: 'nhsd-supplier-id',
5860
APIM_CORRELATION_HEADER: 'nhsd-correlation-id',
5961
LETTERS_TABLE_NAME: 'letters-table',
62+
MI_TABLE_NAME: 'mi-table',
6063
LETTER_TTL_HOURS: 12960,
6164
DOWNLOAD_URL_TTL_SECONDS: 60,
6265
MAX_LIMIT: undefined

lambdas/api-handler/src/handlers/__tests__/post-mi.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('postMI API Handler', () => {
5757
const event = makeApiGwEvent({
5858
path: '/mi',
5959
body: requestBody,
60-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
60+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
6161
});
6262

6363
mockedPostMIOperation.mockResolvedValue(postMIResponse);
@@ -80,7 +80,7 @@ describe('postMI API Handler', () => {
8080
const event = makeApiGwEvent({
8181
path: '/mi',
8282
body: JSON.stringify(modifiedRequest),
83-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
83+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
8484
});
8585

8686
const postMI = createPostMIHandler(mockedDeps);
@@ -94,7 +94,7 @@ describe('postMI API Handler', () => {
9494
it('returns 400 Bad Request when there is no body', async () => {
9595
const event = makeApiGwEvent({
9696
path: '/mi',
97-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
97+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
9898
});
9999

100100
const postMI = createPostMIHandler(mockedDeps);
@@ -111,7 +111,7 @@ describe('postMI API Handler', () => {
111111
path: '/mi',
112112
body: requestBody,
113113
pathParameters: {id: 'id1'},
114-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
114+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
115115
});
116116
mockedPostMIOperation.mockRejectedValue(new Error());
117117

@@ -123,26 +123,26 @@ describe('postMI API Handler', () => {
123123
}));
124124
});
125125

126-
it('returns 400 Bad Request when supplier id is missing', async () => {
126+
it('returns 500 Bad Request when supplier id is missing', async () => {
127127
const event = makeApiGwEvent({
128128
path: '/mi',
129129
body: requestBody,
130-
headers: {'nhsd-correlation-id': 'correlationId'}
130+
headers: {'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
131131
});
132132

133133
const postMI = createPostMIHandler(mockedDeps);
134134
const result = await postMI(event, mockDeep<Context>(), jest.fn());
135135

136136
expect(result).toEqual(expect.objectContaining({
137-
statusCode: 400
137+
statusCode: 500
138138
}));
139139
});
140140

141141
it('returns 500 Internal Server Error when correlation id is missing', async () => {
142142
const event = makeApiGwEvent({
143143
path: '/mi',
144144
body: requestBody,
145-
headers: {'nhsd-supplier-id': 'supplier1'}
145+
headers: {'nhsd-supplier-id': 'supplier1', 'x-request-id': 'requestId'}
146146
});
147147

148148
const postMI = createPostMIHandler(mockedDeps);
@@ -157,7 +157,7 @@ describe('postMI API Handler', () => {
157157
const event = makeApiGwEvent({
158158
path: '/mi',
159159
body: '{"test": "test"}',
160-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
160+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
161161
});
162162

163163
const postMI = createPostMIHandler(mockedDeps);
@@ -172,7 +172,7 @@ describe('postMI API Handler', () => {
172172
const event = makeApiGwEvent({
173173
path: '/mi',
174174
body: '{#invalidJSON',
175-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
175+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
176176
});
177177

178178
const postMI = createPostMIHandler(mockedDeps);
@@ -187,7 +187,7 @@ describe('postMI API Handler', () => {
187187
const event = makeApiGwEvent({
188188
path: '/mi',
189189
body: requestBody,
190-
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId'}
190+
headers: {'nhsd-supplier-id': 'supplier1', 'nhsd-correlation-id': 'correlationId', 'x-request-id': 'requestId'}
191191
});
192192
const spy = jest.spyOn(JSON, 'parse').mockImplementation(() => {
193193
throw 'Unexpected error';

0 commit comments

Comments
 (0)