mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-17 08:20:12 +00:00
* refactor: say who chose the path wherever a job is built from one * refactor: rename SavedItem to Deployed, checked when saved * refactor: trigger pushes are deployed, test connection named by the tester * chore: update ee-repo-ref to bf04cefe64776cb7262f041105b6ceca2953d5f4 This commit updates the EE repository reference after PR #976 was merged in windmill-ee-private. Previous ee-repo-ref: 2276bc7f7f711d6ef33a5133ca87e78ae0fa345a New ee-repo-ref: bf04cefe64776cb7262f041105b6ceca2953d5f4 Automated by sync-ee-ref workflow. --------- Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
78 lines
2.7 KiB
Rust
78 lines
2.7 KiB
Rust
#![cfg(feature = "deno_core")]
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use serde_json::json;
|
|
use sqlx::{Pool, Postgres};
|
|
use windmill_common::{flows::Retry, jobs::JobTriggerKind, triggers::TriggerMetadata};
|
|
use windmill_queue::PushArgsOwned;
|
|
use windmill_test_utils::*;
|
|
|
|
/// A trigger with a retry or an error handler runs its target as the only step of a flow.
|
|
/// A Hub script step is addressed by path, and must still run the script's preprocessor
|
|
/// on the trigger's `event`, as the same trigger without a retry does.
|
|
#[sqlx::test(fixtures("base"))]
|
|
async fn hub_target_with_retry_runs_its_preprocessor(db: Pool<Postgres>) -> anyhow::Result<()> {
|
|
initialize_tracing().await;
|
|
let server = ApiServer::start(db.clone()).await?;
|
|
|
|
let version = "990000004";
|
|
let hub_dir = &*windmill_common::worker::HUB_CACHE_DIR;
|
|
tokio::fs::create_dir_all(hub_dir).await?;
|
|
tokio::fs::write(
|
|
format!("{hub_dir}/{version}"),
|
|
json!({
|
|
"content": "export async function preprocessor(event: any) { return { x: `pre:${event.kind}` } }\n\
|
|
export async function main(x: string) { return x }\n",
|
|
"lockfile": "{}\n//bun.lock\n<empty>",
|
|
"language": "bun",
|
|
"schema": {},
|
|
"summary": null,
|
|
})
|
|
.to_string(),
|
|
)
|
|
.await?;
|
|
|
|
let retry: Retry =
|
|
serde_json::from_value(json!({ "constant": { "attempts": 1, "seconds": 1 } }))?;
|
|
let args = PushArgsOwned {
|
|
args: HashMap::from([(
|
|
"event".to_string(),
|
|
serde_json::value::to_raw_value(&json!({ "kind": "http" }))?,
|
|
)]),
|
|
extra: None,
|
|
};
|
|
let listener = listen_for_completed_jobs(&db).await;
|
|
let (id, _, _, _, _) = windmill_trigger::trigger_helpers::trigger_runnable_inner(
|
|
&db,
|
|
None,
|
|
None,
|
|
windmill_api_auth::ApiAuthed {
|
|
email: "test@windmill.dev".to_string(),
|
|
username: "test-user".to_string(),
|
|
is_admin: true,
|
|
..Default::default()
|
|
},
|
|
windmill_common::jobs::ChosenBy::Deployed,
|
|
"test-workspace",
|
|
&windmill_common::runnable_ref::RunnableRef::from_path(
|
|
&format!("hub/{version}/test/pre"),
|
|
false,
|
|
)?,
|
|
args,
|
|
Some(&sqlx::types::Json(retry)),
|
|
None,
|
|
None,
|
|
"u/test-user/route".to_string(),
|
|
None,
|
|
TriggerMetadata::new(Some("u/test-user/route".to_string()), JobTriggerKind::Http),
|
|
None,
|
|
)
|
|
.await?;
|
|
|
|
in_test_worker(&db, listener.find(&id), server.addr.port()).await;
|
|
let job = completed_job(id, &db).await;
|
|
assert_eq!(job.json_result(), Some(json!("pre:http")));
|
|
Ok(())
|
|
}
|