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: 0 additions & 4 deletions pkg/cli/audit_cross_run_render.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ func renderMarkdownExecutiveSummaryToWriter(w io.Writer, report *CrossRunAuditRe
fmt.Fprintln(w)
}

func renderMarkdownMetricsTrend(mt MetricsTrendData) {
renderMarkdownMetricsTrendToWriter(os.Stdout, mt)
}

func renderMarkdownMetricsTrendToWriter(w io.Writer, mt MetricsTrendData) {
if mt.TotalTokens == 0 && mt.TotalTurns == 0 && mt.AvgDurationNs == 0 {
return
Expand Down
24 changes: 0 additions & 24 deletions pkg/cli/audit_cross_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,30 +312,6 @@ func TestRenderCrossRunReportMarkdown(t *testing.T) {
assert.Contains(t, output, "api.github.com:443", "Should contain the domain")
}

func TestRenderMarkdownMetricsTrend_IncludesTurnsWithoutTokens(t *testing.T) {
oldStdout := os.Stdout
r, w, err := os.Pipe()
require.NoError(t, err, "should create stdout pipe")
os.Stdout = w

renderMarkdownMetricsTrend(MetricsTrendData{
TotalTurns: 9,
AvgTurns: 4.5,
MaxTurns: 6,
})

w.Close()
os.Stdout = oldStdout

var buf bytes.Buffer
_, err = buf.ReadFrom(r)
require.NoError(t, err, "should read captured stdout")
output := buf.String()

assert.Contains(t, output, "## Metrics Trends", "Should render metrics section when turn metrics exist")
assert.Contains(t, output, "| Turns | 9 | 4.5 | — | 6 | — |", "Should render turns row without tokens")
}

func TestRenderPrettyMetricsTrend_IncludesDurationWithoutTokens(t *testing.T) {
Comment on lines 314 to 315

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage gap: deleting this test removes the only coverage for the TotalTurns > 0 && TotalTokens == 0 branch in renderMarkdownMetricsTrendToWriter.

💡 Suggested fix

The test tested the now-dead wrapper (renderMarkdownMetricsTrend), but the interesting assertion — that the Turns row renders correctly when no token data exists — tests the underlying renderMarkdownMetricsTrendToWriter logic, which is still live. The wrapper removal does not justify deleting the coverage.

The remaining integration test TestRenderCrossRunReportMarkdown_IncludesNewSections always supplies both TotalTokens and TotalTurns, so it never exercises lines 79–82 of the render file:

if mt.TotalTurns > 0 {
    fmt.Fprintf(w, "| Turns | %d | %.1f | — | %d | — |\\n",
        mt.TotalTurns, mt.AvgTurns, mt.MaxTurns)
}

Instead of deleting, migrate the test to call renderMarkdownMetricsTrendToWriter directly:

func TestRenderMarkdownMetricsTrendToWriter_TurnsOnlyNoTokens(t *testing.T) {
    var buf bytes.Buffer
    renderMarkdownMetricsTrendToWriter(&buf, MetricsTrendData{
        TotalTurns: 9,
        AvgTurns:   4.5,
        MaxTurns:   6,
    })
    output := buf.String()
    assert.Contains(t, output, "## Metrics Trends", "Should render metrics section when turn metrics exist")
    assert.Contains(t, output, "| Turns | 9 | 4.5 | — | 6 | — |", "Should render turns row without tokens")
}

This also eliminates the flaky os.Stdout swap antipattern from the deleted test.

oldStderr := os.Stderr
r, w, err := os.Pipe()
Expand Down
Loading