Skip to content

Commit

Permalink
Created more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fargekritt committed Dec 27, 2024
1 parent 3661f12 commit 04dec21
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions tests/k6/tests/serviceowner/dialogCreateIdempotentId.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export default function () {
dialog.idempotentId = idempotentId;
let r = postSO('dialogs', dialog);
expectStatusFor(r).to.equal(201);

expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);

dialogs.push({
id: r.json(),
org: null
Expand All @@ -38,6 +40,7 @@ export default function () {

let responseNav = postSO('dialogs', dialog, null, navOrg);
expectStatusFor(responseNav).to.equal(201);

expect(responseNav, 'response').to.have.validJsonBody();
expect(responseNav.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);

Expand All @@ -51,6 +54,7 @@ export default function () {

let responseDigdir = postSO('dialogs', dialog);
expectStatusFor(responseDigdir).to.equal(201);

expect(responseDigdir, 'response').to.have.validJsonBody();
expect(responseDigdir.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);

Expand All @@ -68,23 +72,42 @@ export default function () {
dialog.idempotentId = idempotentId;
let r = postSO('dialogs', dialog);
expectStatusFor(r).to.equal(201);

expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.match(/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/);


let dialogId = r.json();
dialogs.push({
id: r.json(),
id: dialogId,
org: null
});

r = postSO('dialogs', dialog);
expectStatusFor(r).to.equal(409);

expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.property('errors');
expect(r.json()['errors'], 'response json errors').to.property('Conflict');
expect(r.json()['errors']['Conflict'][0], 'response json Conflict').to.contain(dialogId);
})

describe('Attempt to create dialog with too long idempotentId', () => {
let dialog = dialogToInsert();
let idempotentId = "this idempotent id is way to long the length of this idempotent id exceeds the 36 character limit";

dialog.idempotentId = idempotentId;

let r = postSO('dialogs', dialog);
expectStatusFor(r).to.equal(400);

expect(r, 'response').to.have.validJsonBody();
expect(r.json(), 'response json').to.have.property('errors');

})

describe('Cleanup', () => {
let i;
for (i = 0; i < dialogs.length; i++) {
console.log('Purging dialog ' + dialogs[i])
let r = purgeSO('dialogs/' + dialogs[i].id, null, dialogs[i].org);
expectStatusFor(r).to.equal(204);
}
Expand Down

0 comments on commit 04dec21

Please sign in to comment.