Skip to content

Commit

Permalink
Add test for auto-generating UUID
Browse files Browse the repository at this point in the history
  • Loading branch information
ktuite committed Feb 13, 2024
1 parent 584b4b0 commit 9b11b48
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion test/integration/api/entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ describe('Entities API', () => {
},
entities: [
{
uuid: '12345678-1234-4123-8234-111111111aaa', // TODO: don't require UUIDs
uuid: '12345678-1234-4123-8234-111111111aaa',
label: 'Johnny Doe',
data: {
first_name: 'Johnny',
Expand Down Expand Up @@ -2152,6 +2152,52 @@ describe('Entities API', () => {
});
}));


it('should generate uuids for entities when no uuid is provided', testDataset(async (service) => {
const asAlice = await service.login('alice');

await asAlice.get('/v1/projects/1/datasets/people/entities')
.then(({ body }) => {
body.length.should.equal(0);
});

await asAlice.post('/v1/projects/1/datasets/people/entities')
.send({
source: {
name: 'people.csv',
size: 100,
},
entities: [
{
uuid: '12345678-1234-4123-8234-111111111aaa',
label: 'Johnny Doe',
data: {
first_name: 'Johnny',
age: '22'
}
},
{
label: 'Alice',
data: {
first_name: 'Alice',
age: '44'
}
},
]
})
.expect(200)
.then(({ body }) => {
body.success.should.be.true();
});

// Used provided UUID and generated other UUID
await asAlice.get('/v1/projects/1/datasets/people/entities')
.then(({ body }) => {
body[0].uuid.should.equal('12345678-1234-4123-8234-111111111aaa');
body[1].uuid.should.be.a.uuid();
});
}));

describe('bulk create errors', () => {
it('should not create any entities if one is invalid (missing label)', testDataset(async (service) => {
const asAlice = await service.login('alice');
Expand Down

0 comments on commit 9b11b48

Please sign in to comment.