Skip to content

Commit 40a4043

Browse files
committed
use constant for nonexistent entity
1 parent be81483 commit 40a4043

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

test/integration/api/entities.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const { Entity } = require('../../../lib/model/frames');
1111

1212
const { exhaust } = require(appRoot + '/lib/worker/worker');
1313

14+
const NONEXISTENT_ENTITY = '00000000-0000-4000-8000-000000000000';
15+
1416
const testDataset = (test) => testService(async (service, container) => {
1517
const asAlice = await service.login('alice');
1618

@@ -244,14 +246,14 @@ describe('Entities API', () => {
244246
it('should return notfound if the dataset does not exist', testEntities(async (service) => {
245247
const asAlice = await service.login('alice');
246248

247-
await asAlice.get('/v1/projects/1/datasets/nonexistent/entities/00000000-0000-4000-8000-000000000000')
249+
await asAlice.get(`/v1/projects/1/datasets/nonexistent/entities/${NONEXISTENT_ENTITY}`)
248250
.expect(404);
249251
}));
250252

251253
it('should return notfound if the entity does not exist', testEntities(async (service) => {
252254
const asAlice = await service.login('alice');
253255

254-
await asAlice.get('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000')
256+
await asAlice.get(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}`)
255257
.expect(404);
256258
}));
257259

@@ -496,7 +498,7 @@ describe('Entities API', () => {
496498
it('should return notfound if the entity does not exist', testEntities(async (service) => {
497499
const asAlice = await service.login('alice');
498500

499-
await asAlice.get('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000/versions')
501+
await asAlice.get(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}/versions`)
500502
.expect(404);
501503
}));
502504

@@ -815,7 +817,7 @@ describe('Entities API', () => {
815817
it('should return notfound if the entity does not exist', testEntities(async (service) => {
816818
const asAlice = await service.login('alice');
817819

818-
await asAlice.get('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000/diffs')
820+
await asAlice.get(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}/diffs`)
819821
.expect(404);
820822
}));
821823

@@ -872,7 +874,7 @@ describe('Entities API', () => {
872874
it('should return notfound if the entity does not exist', testEntities(async (service) => {
873875
const asAlice = await service.login('alice');
874876

875-
await asAlice.get('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000/audits')
877+
await asAlice.get(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}/audits`)
876878
.expect(404);
877879
}));
878880

@@ -1539,19 +1541,19 @@ describe('Entities API', () => {
15391541
describe('PATCH /datasets/:name/entities/:uuid', () => {
15401542
it('should return notfound if the dataset does not exist', testEntities(async (service) => {
15411543
const asAlice = await service.login('alice');
1542-
await asAlice.patch('/v1/projects/1/datasets/nonexistent/entities/00000000-0000-4000-8000-000000000000')
1544+
await asAlice.patch(`/v1/projects/1/datasets/nonexistent/entities/${NONEXISTENT_ENTITY}`)
15431545
.expect(404);
15441546
}));
15451547

15461548
it('should return notfound if the entity does not exist', testEntities(async (service) => {
15471549
const asAlice = await service.login('alice');
1548-
await asAlice.patch('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000')
1550+
await asAlice.patch(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}`)
15491551
.expect(404);
15501552
}));
15511553

15521554
it('should reject if the user cannot update', testEntities(async (service) => {
15531555
const asChelsea = await service.login('chelsea');
1554-
await asChelsea.patch('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000')
1556+
await asChelsea.patch(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}`)
15551557
.expect(403);
15561558
}));
15571559

@@ -2111,14 +2113,14 @@ describe('Entities API', () => {
21112113
it('should return notfound if the dataset does not exist', testEntities(async (service) => {
21122114
const asAlice = await service.login('alice');
21132115

2114-
await asAlice.delete('/v1/projects/1/datasets/nonexistent/entities/00000000-0000-4000-8000-000000000000')
2116+
await asAlice.delete(`/v1/projects/1/datasets/nonexistent/entities/${NONEXISTENT_ENTITY}`)
21152117
.expect(404);
21162118
}));
21172119

21182120
it('should return notfound if the entity does not exist', testEntities(async (service) => {
21192121
const asAlice = await service.login('alice');
21202122

2121-
await asAlice.delete('/v1/projects/1/datasets/people/entities/00000000-0000-4000-8000-000000000000')
2123+
await asAlice.delete(`/v1/projects/1/datasets/people/entities/${NONEXISTENT_ENTITY}`)
21222124
.expect(404);
21232125
}));
21242126

@@ -2175,7 +2177,7 @@ describe('Entities API', () => {
21752177
it('should reject if the entity does not exist', testEntities(async (service) => {
21762178
const asAlice = await service.login('alice');
21772179

2178-
await asAlice.post('/v1/projects/1/datasets/people/entities/uuid:00000000-0000-4000-8000-000000000000/restore')
2180+
await asAlice.post(`/v1/projects/1/datasets/people/entities/uuid:${NONEXISTENT_ENTITY}/restore`)
21792181
.expect(404);
21802182
}));
21812183

@@ -2987,7 +2989,7 @@ describe('Entities API', () => {
29872989

29882990
await asAlice.post('/v1/projects/1/datasets/people/entities/bulk-delete')
29892991
.send({
2990-
ids: ['12345678-1234-4123-8234-0123456789ab']
2992+
ids: [NONEXISTENT_ENTITY]
29912993
})
29922994
.expect(200)
29932995
.then(({ body }) => {
@@ -3098,7 +3100,7 @@ describe('Entities API', () => {
30983100

30993101
await asAlice.post('/v1/projects/1/datasets/people/entities/bulk-restore')
31003102
.send({
3101-
ids: ['12345678-1234-4123-8234-0123456789ab']
3103+
ids: [NONEXISTENT_ENTITY]
31023104
})
31033105
.expect(200)
31043106
.then(({ body }) => {
@@ -3179,7 +3181,7 @@ describe('Entities API', () => {
31793181
// Try to restore both a valid deleted entity and a nonexistent one
31803182
await asAlice.post('/v1/projects/1/datasets/people/entities/bulk-restore')
31813183
.send({
3182-
ids: ['12345678-1234-4123-8234-123456789abc', '12345678-1234-4123-8234-0123456789ab']
3184+
ids: ['12345678-1234-4123-8234-123456789abc', NONEXISTENT_ENTITY]
31833185
})
31843186
.expect(200)
31853187
.then(({ body }) => {

0 commit comments

Comments
 (0)