Skip to content

Commit cf83992

Browse files
committed
revert the upsert change and fix the test
1 parent 595e4c7 commit cf83992

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

spec/CloudCode.spec.js

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,30 +1547,38 @@ describe('Cloud Code', () => {
15471547
});
15481548

15491549
describe('cloud jobs', () => {
1550-
it('should define a job', done => {
1551-
expect(() => {
1552-
Parse.Cloud.job('myJob', ({ message }) => {
1553-
message('Hello, world!!!');
1554-
});
1555-
}).not.toThrow();
1550+
for (let x = 0; x < 1000; x++) {
1551+
fit('should define a job', done => {
1552+
expect(() => {
1553+
Parse.Cloud.job('myJob', ({ message }) => {
1554+
message('Hello, world!!!');
1555+
});
1556+
}).not.toThrow();
15561557

1557-
request({
1558-
method: 'POST',
1559-
url: 'http://localhost:8378/1/jobs/myJob',
1560-
headers: {
1561-
'X-Parse-Application-Id': Parse.applicationId,
1562-
'X-Parse-Master-Key': Parse.masterKey,
1563-
},
1564-
}).then(
1565-
() => {
1566-
done();
1567-
},
1568-
err => {
1569-
fail(err);
1570-
done();
1571-
}
1572-
);
1573-
});
1558+
request({
1559+
method: 'POST',
1560+
url: 'http://localhost:8378/1/jobs/myJob',
1561+
headers: {
1562+
'X-Parse-Application-Id': Parse.applicationId,
1563+
'X-Parse-Master-Key': Parse.masterKey,
1564+
},
1565+
})
1566+
.then(async response => {
1567+
const jobStatusId = response.headers['x-parse-job-status-id'];
1568+
const checkJobStatus = async () => {
1569+
const jobStatus = await new Parse.Query('_JobStatus').get(jobStatusId, {
1570+
useMasterKey: true,
1571+
});
1572+
return jobStatus.get('finishedAt') && jobStatus.get('message') === 'Hello, world!!!';
1573+
};
1574+
while (!(await checkJobStatus())) {
1575+
await new Promise(resolve => setTimeout(resolve, 100));
1576+
}
1577+
})
1578+
.then(done)
1579+
.catch(done.fail);
1580+
});
1581+
}
15741582

15751583
it('should not run without master key', done => {
15761584
expect(() => {

src/StatusHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function statusHandler(className, database) {
4141

4242
function update(where, object) {
4343
lastPromise = lastPromise.then(() => {
44-
return database.update(className, where, object, { upsert: true });
44+
return database.update(className, where, object);
4545
});
4646
return lastPromise;
4747
}

0 commit comments

Comments
 (0)