Overview
Add JSON output format support to the test command (roadmap task 12.8). This is part of Phase 2 of the JSON output epic (#348), which aims to implement JSON output for all remaining commands so that JSON can eventually become the default output format.
The test command currently only outputs human-readable text progress messages and DNS warnings. This task adds a machine-readable JSON alternative that automation workflows, CI/CD pipelines, and AI agents can parse programmatically.
Key difference from other commands: The test command does not transition environment state. It loads the current environment (any state), validates running services, and returns a TestResult containing pass/fail status and advisory DNS warnings. The JSON output schema reflects this test-result nature rather than the environment-state pattern used by other commands.
Specification
See detailed specification: docs/issues/380-add-json-output-to-test-command.md
🏗️ Architecture Requirements
DDD Layer: Presentation
Module Path: src/presentation/views/commands/test/
Pattern: Strategy Pattern for rendering
Module Structure Requirements
Architectural Constraints
Anti-Patterns to Avoid
- ❌ Mixing rendering concerns in the controller
- ❌ Adding business logic to view structs
- ❌ Using
println!/eprintln! instead of UserOutput
Implementation Plan
Step 1: Create View Module Structure
Step 2: Extend TestResult (Application Layer)
Step 3: Implement DTO
Step 4: Implement Views
Step 5: Update Controller
Step 6: Update Router
Step 7: Add Tests
Step 8: Documentation
Acceptance Criteria
Note for Contributors: These criteria define what the PR reviewer will check. Use this as your pre-review checklist before submitting the PR to minimize back-and-forth iterations.
Quality Checks:
Task-Specific Criteria:
Related
Overview
Add JSON output format support to the
testcommand (roadmap task 12.8). This is part of Phase 2 of the JSON output epic (#348), which aims to implement JSON output for all remaining commands so that JSON can eventually become the default output format.The
testcommand currently only outputs human-readable text progress messages and DNS warnings. This task adds a machine-readable JSON alternative that automation workflows, CI/CD pipelines, and AI agents can parse programmatically.Key difference from other commands: The
testcommand does not transition environment state. It loads the current environment (any state), validates running services, and returns aTestResultcontaining pass/fail status and advisory DNS warnings. The JSON output schema reflects this test-result nature rather than the environment-state pattern used by other commands.Specification
See detailed specification: docs/issues/380-add-json-output-to-test-command.md
🏗️ Architecture Requirements
DDD Layer: Presentation
Module Path:
src/presentation/views/commands/test/Pattern: Strategy Pattern for rendering
Module Structure Requirements
Architectural Constraints
Anti-Patterns to Avoid
println!/eprintln!instead ofUserOutputImplementation Plan
Step 1: Create View Module Structure
src/presentation/views/commands/test/withmod.rs,view_data/,views/Step 2: Extend TestResult (Application Layer)
instance_ip: IpAddrfield toTestResultStep 3: Implement DTO
TestResultDataandDnsWarningDatastructsTestResultData::new()constructorStep 4: Implement Views
JsonView::render()with inline error handlingTextView::render()with formatted text outputStep 5: Update Controller
output_format: OutputFormatparameter toexecute()fixture_infrastructure()to returnTestResultcomplete_workflow()Step 6: Update Router
output_formatfrom context to controllerStep 7: Add Tests
Step 8: Documentation
docs/user-guide/commands/test.mdwith JSON output examplesAcceptance Criteria
Quality Checks:
./scripts/pre-commit.shTask-Specific Criteria:
testcommand accepts--output-format jsonflagenvironment_name,instance_ip,result, anddns_warningsfieldsdns_warningsarray correctly serializes warning details (domain, expected_ip, issue)Related