mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-21 00:02:30 +00:00
test: keep the webhook doc comment with the test it describes
This commit is contained in:
@@ -1436,6 +1436,56 @@ async fn test_no_alert_in_config_table_after_migration(db: Pool<Postgres>) {
|
||||
/// validating `github_app_webhook_base_url` itself. A rejected value must not be
|
||||
/// half-applied: nothing at all may be written, or an unreachable receiver would be
|
||||
/// persisted and only surface much later as a repository falling back to polling.
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn declarative_sync_rejects_an_unusable_webhook_base_url(db: Pool<Postgres>) {
|
||||
clear_settings_and_configs(&db).await;
|
||||
let before = count_global_settings(&db).await;
|
||||
|
||||
let mut desired = BTreeMap::new();
|
||||
desired.insert("base_url".to_string(), serde_json::json!("https://wm.example.com"));
|
||||
desired.insert(
|
||||
"github_app_webhook_base_url".to_string(),
|
||||
serde_json::json!("httpss://hooks.example.com"),
|
||||
);
|
||||
|
||||
let err = windmill_common::instance_config::sync_global_settings_declarative(
|
||||
&db,
|
||||
&BTreeMap::new(),
|
||||
&desired,
|
||||
)
|
||||
.await
|
||||
.expect_err("an invalid webhook base url must fail the sync");
|
||||
assert!(
|
||||
err.to_string().contains("github_app_webhook_base_url"),
|
||||
"the error should name the offending setting, got: {err}"
|
||||
);
|
||||
|
||||
// A non-string shape must be rejected too, not silently treated as "absent" and
|
||||
// then persisted by the diff.
|
||||
let mut wrong_type = BTreeMap::new();
|
||||
wrong_type.insert(
|
||||
"github_app_webhook_base_url".to_string(),
|
||||
serde_json::json!(true),
|
||||
);
|
||||
windmill_common::instance_config::sync_global_settings_declarative(
|
||||
&db,
|
||||
&BTreeMap::new(),
|
||||
&wrong_type,
|
||||
)
|
||||
.await
|
||||
.expect_err("a non-string webhook base url must fail the sync");
|
||||
|
||||
assert_eq!(
|
||||
count_global_settings(&db).await,
|
||||
before,
|
||||
"validation must run before anything is applied"
|
||||
);
|
||||
assert!(
|
||||
get_global_setting(&db, "base_url").await.is_none(),
|
||||
"the other settings in the same apply must not have been written either"
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn declarative_sync_rejects_an_unusable_default_allowed_origins(db: Pool<Postgres>) {
|
||||
// The declarative writers (the sync-config CLI, the operator's ConfigMap
|
||||
@@ -1489,53 +1539,3 @@ async fn declarative_sync_rejects_an_unusable_default_allowed_origins(db: Pool<P
|
||||
.await
|
||||
.expect("a valid origin list must sync");
|
||||
}
|
||||
|
||||
#[sqlx::test(fixtures("base"))]
|
||||
async fn declarative_sync_rejects_an_unusable_webhook_base_url(db: Pool<Postgres>) {
|
||||
clear_settings_and_configs(&db).await;
|
||||
let before = count_global_settings(&db).await;
|
||||
|
||||
let mut desired = BTreeMap::new();
|
||||
desired.insert("base_url".to_string(), serde_json::json!("https://wm.example.com"));
|
||||
desired.insert(
|
||||
"github_app_webhook_base_url".to_string(),
|
||||
serde_json::json!("httpss://hooks.example.com"),
|
||||
);
|
||||
|
||||
let err = windmill_common::instance_config::sync_global_settings_declarative(
|
||||
&db,
|
||||
&BTreeMap::new(),
|
||||
&desired,
|
||||
)
|
||||
.await
|
||||
.expect_err("an invalid webhook base url must fail the sync");
|
||||
assert!(
|
||||
err.to_string().contains("github_app_webhook_base_url"),
|
||||
"the error should name the offending setting, got: {err}"
|
||||
);
|
||||
|
||||
// A non-string shape must be rejected too, not silently treated as "absent" and
|
||||
// then persisted by the diff.
|
||||
let mut wrong_type = BTreeMap::new();
|
||||
wrong_type.insert(
|
||||
"github_app_webhook_base_url".to_string(),
|
||||
serde_json::json!(true),
|
||||
);
|
||||
windmill_common::instance_config::sync_global_settings_declarative(
|
||||
&db,
|
||||
&BTreeMap::new(),
|
||||
&wrong_type,
|
||||
)
|
||||
.await
|
||||
.expect_err("a non-string webhook base url must fail the sync");
|
||||
|
||||
assert_eq!(
|
||||
count_global_settings(&db).await,
|
||||
before,
|
||||
"validation must run before anything is applied"
|
||||
);
|
||||
assert!(
|
||||
get_global_setting(&db, "base_url").await.is_none(),
|
||||
"the other settings in the same apply must not have been written either"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user