Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/cli/commands/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ func formatText(report *engine.DiagnosisReport) string {
}

out += fmt.Sprintf("%d. %s %s\n", i+1, status, result.ID)
out += fmt.Sprintf(" Status: %s | Severity: %s | Confidence: %.0f%%\n",
result.Status, result.Severity, result.Confidence*100)
out += fmt.Sprintf(" Status: %s | Severity: %s | Confidence: %.0f%% [%s]\n",
result.Status, result.Severity, result.Confidence*100, result.ExecutionTime)
out += fmt.Sprintf(" %s\n\n", result.Explanation)
}

Expand Down
41 changes: 41 additions & 0 deletions cmd/cli/commands/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,47 @@ func TestFormatHTMLIncludesSummaryAndEvidence(t *testing.T) {
}
}

// TestFormatTextIncludesPerCheckExecutionTime guards #43: every check result
// already carries ExecutionTime, but formatText never rendered it, so users
// could not see which check was slow. The duration must appear, human-readable,
// on each result's status line.
func TestFormatTextIncludesPerCheckExecutionTime(t *testing.T) {
report := &engine.DiagnosisReport{
ChecksExecuted: 2,
ChecksFailed: 0,
CriticalFindings: 0,
ExecutionTime: 2 * time.Second,
Results: []check.CheckResult{
{
ID: "public_ip",
Status: check.StatusPassed,
Severity: check.SeverityInfo,
Confidence: 0.95,
Explanation: "Public IP resolved via proxy.",
ExecutionTime: 1200 * time.Millisecond,
},
{
ID: "dns_resolve",
Status: check.StatusPassed,
Severity: check.SeverityInfo,
Confidence: 0.90,
Explanation: "DNS resolved through proxy.",
ExecutionTime: 350 * time.Millisecond,
},
},
}

out := formatText(report)

// time.Duration.String() renders these as "1.2s" and "350ms" — the
// human-readable forms the issue asks for, and they must be bracketed.
for _, want := range []string{"[1.2s]", "[350ms]", "public_ip", "dns_resolve"} {
if !strings.Contains(out, want) {
t.Fatalf("text output missing %q:\n%s", want, out)
}
}
}

func newTestRegistry() *engine.CheckRegistry {
registry := engine.NewCheckRegistry()
if err := checkspkg.RegisterDefaults(registry); err != nil {
Expand Down