Fixed tests

Signed-off-by: Alex Lorenzi <alorenzi@spotify.com>
This commit is contained in:
Alex Lorenzi
2025-02-12 16:13:18 -05:00
parent b78e3fdb71
commit 5cab95a0b3
2 changed files with 21 additions and 3 deletions
@@ -164,7 +164,14 @@ describe('createRouter', () => {
.set('accept', 'text/event-stream')
.send();
expect(response.status).toBe(404);
expect(response.status).toBe(200);
expect(response.get('content-type')).toBe('text/event-stream');
expect(response.text).toEqual(
`event: error
data: "Entity not found"
`,
);
});
it('should return not found if entity has no uid', async () => {
@@ -179,7 +186,14 @@ describe('createRouter', () => {
.set('accept', 'text/event-stream')
.send();
expect(response.status).toBe(404);
expect(response.status).toBe(200);
expect(response.get('content-type')).toBe('text/event-stream');
expect(response.text).toEqual(
`event: error
data: "Entity metadata UID missing"
`,
);
});
it('should not check for an update when shouldBuild returns false', async () => {
@@ -246,7 +246,11 @@ export async function createRouter(
const entity = await entityLoader.load({ kind, namespace, name }, token);
if (!entity?.metadata?.uid) {
responseHandler.error(new NotFoundError('Entity metadata UID missing'));
responseHandler.error(
new NotFoundError(
entity ? 'Entity metadata UID missing' : 'Entity not found',
),
);
return;
}