Compare commits

...

1 Commits

Author SHA1 Message Date
HAL9000 a0fae4535e fix(test): add root_plan_id to raw SQL in plan_phase_migration constraint tests
CI / push-validation (pull_request) Successful in 27s
CI / helm (pull_request) Successful in 37s
CI / build (pull_request) Successful in 3m50s
CI / lint (pull_request) Successful in 3m57s
CI / quality (pull_request) Successful in 4m23s
CI / typecheck (pull_request) Successful in 4m40s
CI / security (pull_request) Successful in 4m50s
CI / unit_tests (pull_request) Failing after 5m51s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 7m14s
CI / integration_tests (pull_request) Successful in 7m51s
CI / coverage (pull_request) Successful in 15m0s
CI / status-check (pull_request) Failing after 3s
The step_try_insert_plan_with_phase_and_state function was using raw SQL to
insert a plan with an invalid phase value to test the CHECK constraint. However,
the raw SQL was missing the root_plan_id column, which is NOT NULL in the schema.
This caused the insert to fail with a NOT NULL violation instead of the intended
CHECK constraint violation on the phase column.

This fix adds root_plan_id to the raw SQL INSERT statement, setting it to the
same value as plan_id (for a root plan). This allows the test to properly
exercise the CHECK constraint on the phase column, ensuring the test fails for
the correct reason.

ISSUES CLOSED: #9411
2026-04-15 16:38:29 +00:00
+8 -3
View File
@@ -113,7 +113,11 @@ def step_insert_plan_with_phase_and_state(context: Any, phase: str, state: str)
def step_try_insert_plan_with_phase_and_state(
context: Any, phase: str, state: str
) -> None:
"""Try to insert a plan with the specified phase and state, expecting failure."""
"""Try inserting a plan without ORM defaults to exercise the phase constraint.
The direct SQL insert must provide both plan_id and root_plan_id so the
phase constraint is validated instead of failing on missing root_plan_id.
"""
session: Session = context.phase_rebaseline_session
ulid = _next_ulid()
now = _now_iso()
@@ -121,14 +125,15 @@ def step_try_insert_plan_with_phase_and_state(
session.execute(
text(
"INSERT INTO v3_plans "
"(plan_id, action_name, namespaced_name, namespace, "
"(plan_id, root_plan_id, action_name, namespaced_name, namespace, "
"phase, processing_state, description, tags_json, "
"created_at, updated_at) "
"VALUES (:pid, :aname, :nname, :ns, :phase, :state, "
"VALUES (:pid, :rpid, :aname, :nname, :ns, :phase, :state, "
":desc, :tags, :cat, :uat)"
),
{
"pid": ulid,
"rpid": ulid,
"aname": "local/phase-test-action",
"nname": "local/try-plan",
"ns": "local",