I have an API that gets the status of a job. It parses the response body and looks for the "state:" of the job.
If it's INPROGRESS I'm telling the request to wait 10 seconds and rerun, but this doesn't happen, it just moves on to the next.
This is the Test I'm running:
pm.environment.unset("JobStatus");
var jsonData = pm.response.json();
pm.environment.set("JobStatus", jsonData['progress-update'].state);
const sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
pm.environment.get("JobStatus");
if ( environment.JobStatus == "DONE")
{
postman.setNextRequest("Export Results");
}
else if ( environment.JobStatus == "INPROGRESS")
{
sleep(10000).then(() => {
postman.setNextRequest("Get Job Status");
})}
else {
postman.setNextRequest(null);
}
The data has a main Task that i'm checking for and then many subtasks with the same state INPROGRESS string.
{
"progress-update": {
"@type": "parallel-progress",
"job": {
"@href": "/api/space/job-management/jobs/4755716"
},
"taskId": 4755716,
"jobName": "Compare Config-4755716",
"state": "INPROGRESS",
"status": "UNDETERMINED",
"percentage": 10,
"subTask": [
{
"@type": "percentage-complete",
"state": "INPROGRESS",
"status": "UNDETERMINED",
"percentage": 0
},
The variable is being set correctly, but my else if statement is not being followed.

Aucun commentaire:
Enregistrer un commentaire