fix forloop empty no step afterward

This commit is contained in:
Ruben Fiszel
2022-08-18 00:01:04 +02:00
parent 775a0e95da
commit 79ec90acfc
2 changed files with 56 additions and 1 deletions
+38 -1
View File
@@ -1390,7 +1390,6 @@ def main():
assert_eq!(result, serde_json::json!("hello world"));
}
#[sqlx::test(fixtures("base"))]
async fn test_empty_loop(db: DB) {
initialize_tracing().await;
@@ -1443,6 +1442,44 @@ def main():
assert_eq!(result, serde_json::json!(0));
}
#[sqlx::test(fixtures("base"))]
async fn test_empty_loop_2(db: DB) {
initialize_tracing().await;
let flow: FlowValue = serde_json::from_value(serde_json::json!({
"modules": [
{
"value": {
"type": "forloopflow",
"iterator": { "type": "static", "value": [] },
"value": {
"modules": [
{
"input_transform": {
"n": {
"type": "javascript",
"expr": "previous_result.iter.value",
},
},
"value": {
"type": "rawscript",
"language": "python3",
"content": "def main(n): return n",
},
}
],
}
},
},
],
}))
.unwrap();
let flow = JobPayload::RawFlow { value: flow, path: None };
let result = run_job_in_new_worker_until_complete(&db, flow).await;
assert_eq!(result, serde_json::json!([]));
}
#[sqlx::test(fixtures("base"))]
async fn test_step_after_loop(db: DB) {
+18
View File
@@ -550,6 +550,24 @@ async fn push_next_flow_job(
push_next_flow_job(&new_job, flow, schedule_path, db, json!([])).await?,
);
} else {
add_completed_job(
db,
&new_job,
true,
false,
json!([]),
"Forloop completed without iteration".to_string(),
)
.await?;
postprocess_queued_job(
false,
new_job.schedule_path,
new_job.script_path,
&new_job.workspace_id,
new_job.id,
db,
)
.await?;
return Ok(());
}
}