Merge pull request 'fix(cli): add deleted_at field to project delete JSON/YAML output' (#6639) from fix/issue-6314-project-delete-output into master
CI / benchmark-publish (push) Waiting to run
CI / lint (push) Successful in 44s
CI / typecheck (push) Successful in 1m15s
CI / security (push) Successful in 1m0s
CI / quality (push) Successful in 57s
CI / benchmark-regression (push) Waiting to run
CI / build (push) Successful in 20s
CI / helm (push) Successful in 23s
CI / push-validation (push) Successful in 32s
CI / e2e_tests (push) Successful in 4m8s
CI / integration_tests (push) Successful in 4m47s
CI / unit_tests (push) Successful in 6m5s
CI / docker (push) Successful in 1m34s
CI / coverage (push) Successful in 12m55s
CI / status-check (push) Successful in 1s

This commit was merged in pull request #6639.
This commit is contained in:
2026-04-10 19:45:43 +00:00
committed by Forgejo
3 changed files with 36 additions and 1 deletions
+5
View File
@@ -196,6 +196,11 @@ Feature: Project CLI command functions coverage
When I invoke project-delete for "local/del-json" with yes format "json"
Then the project cmd output should contain "deleted"
Scenario: delete command JSON includes deletion timestamp
Given a project "local/del-json-ts" is created in the commands DB
When I invoke project-delete for "local/del-json-ts" with yes format "json"
Then the project cmd JSON data should include deleted_at
Scenario: delete nonexistent project fails
When I invoke project-delete for "local/nope" with yes
Then the project cmd should fail
@@ -12,6 +12,7 @@ database, then restored after every step that needs them.
from __future__ import annotations
import json
from io import StringIO
from typing import Any
@@ -675,3 +676,22 @@ def step_cmd_fail(context: Any) -> None:
assert context._cmd_failed, (
f"Expected command to fail but it succeeded. Output:\n{context._cmd_output}"
)
@then("the project cmd JSON data should include deleted_at")
def step_cmd_json_has_deleted_at(context: Any) -> None:
output = context._cmd_output.strip()
try:
envelope = json.loads(output)
except json.JSONDecodeError as exc:
raise AssertionError(
f"Command output is not valid JSON:\n{context._cmd_output}"
) from exc
data = envelope.get("data")
assert isinstance(data, dict), (
f"Expected envelope data to be a dict, got {type(data).__name__}: {data}"
)
assert "deleted_at" in data, (
f"Expected 'deleted_at' in command JSON data, got keys {list(data.keys())}"
)
+11 -1
View File
@@ -19,6 +19,7 @@ Based on ADR-009 (CLI Framework) and implementation_plan.md task B0.cli.projects
from __future__ import annotations
import re
from datetime import UTC, datetime
from pathlib import Path
from typing import Annotated, Any
@@ -977,4 +978,13 @@ def delete(
if output_format.lower() == OutputFormat.RICH:
console.print(f"[green]✓[/green] Project '{name}' deleted.")
else:
console.print(format_output({"deleted": name, "success": True}, output_format))
console.print(
format_output(
{
"deleted": name,
"success": True,
"deleted_at": datetime.now(tz=UTC),
},
output_format,
)
)