Skip to content

Commit 4e061ff

Browse files
committed
check params in job message
1 parent 90c6b69 commit 4e061ff

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

integration/test/IdempotencyTest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ describe('Idempotency', () => {
3434

3535
it('handle duplicate job request', async () => {
3636
DuplicateRequestId('1234');
37-
const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {});
38-
await expectAsync(Parse.Cloud.startJob('CloudJob1', {})).toBeRejectedWithError(
37+
const params = { startedBy: 'Monty Python' };
38+
const jobStatusId = await Parse.Cloud.startJob('CloudJobParamsInMessage', params);
39+
await expectAsync(Parse.Cloud.startJob('CloudJobParamsInMessage', params)).toBeRejectedWithError(
3940
'Duplicate request'
4041
);
4142

@@ -48,6 +49,7 @@ describe('Idempotency', () => {
4849
}
4950
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
5051
expect(jobStatus.get('status')).toBe('succeeded');
52+
expect(JSON.parse(jobStatus.get('message'))).toEqual(params);
5153
});
5254

5355
it('handle duplicate POST / PUT request', async () => {

integration/test/ParseCloudTest.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ describe('Parse Cloud', () => {
9494
});
9595

9696
it('run job', async () => {
97-
const jobStatusId = await Parse.Cloud.startJob('CloudJob1', {});
97+
const params = { startedBy: 'Monty Python' };
98+
const jobStatusId = await Parse.Cloud.startJob('CloudJobParamsInMessage', params);
9899
expect(jobStatusId).toBeDefined();
99100
await waitForJobStatus(jobStatusId, 'succeeded');
100101

101102
const jobStatus = await Parse.Cloud.getJobStatus(jobStatusId);
102-
assert.equal(jobStatus.get('status'), 'succeeded');
103+
expect(jobStatus.get('status')).toBe('succeeded');
104+
expect(JSON.parse(jobStatus.get('message'))).toEqual(params);
103105
});
104106

105107
it('run long job', async () => {

integration/test/cloud/main.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ Parse.Cloud.job('CloudJob2', function () {
4545
});
4646
});
4747

48+
Parse.Cloud.job('CloudJobParamsInMessage', request => {
49+
request.message(JSON.stringify(request.params));
50+
});
51+
4852
Parse.Cloud.job('CloudJobFailing', function () {
4953
throw 'cloud job failed';
5054
});

integration/test/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const defaultConfiguration = {
7474
},
7575
},
7676
idempotencyOptions: {
77-
paths: ['functions/CloudFunctionIdempotency', 'jobs/CloudJob1', 'classes/IdempotentTest'],
77+
paths: ['functions/CloudFunctionIdempotency', 'jobs/CloudJob1', 'jobs/CloudJobParamsInMessage', 'classes/IdempotentTest'],
7878
ttl: 120,
7979
},
8080
fileUpload: {

0 commit comments

Comments
 (0)