Atlas › Test

TestGenerateSuiteBreakdownTable

Exact test identity: go.temporal.io/server/tools/flakereport/TestGenerateSuiteBreakdownTable

Package
go.temporal.io/server/tools/flakereport
Suite / test hierarchy
TestGenerateSuiteBreakdownTable
Test
TestGenerateSuiteBreakdownTable
Introduced at
report.go ×3 Frontier kind: Joint frontier
Covered ranges
5
Covered lines
21
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/tools/flakereport/report.go 21 covered LOC · 5 ranges

Open complete file

13
14 // hoursAgo formats a timestamp as "Xh ago" relative to now.
15 > func hoursAgo(t time.Time) string { report.go
16 > h := math.Round(time.Since(t).Hours())
17 > if h < 1 {
18 h = 1
19 }
20 > return fmt.Sprintf("%dh ago", int(h)) report.go
21 }
22
70
71 // generateSuiteBreakdownTable creates a markdown table of per-suite flake data
72 > func generateSuiteBreakdownTable(suiteReports []SuiteReport) string { report.go
73 > if len(suiteReports) == 0 {
74 return ""
75 }
76
77 > var sb strings.Builder report.go
78 > sb.WriteString("| Suite | Flake Rate | Last Failure |\n")
79 > sb.WriteString("|-------|------------|-------------|\n")
80 >
81 > for _, sr := range suiteReports {
82 > lastFailure := "-"
83 > if sr.FailedRuns > 0 && !sr.LastFailure.IsZero() {
84 > lastFailure = hoursAgo(sr.LastFailure)
85 > }
86 > rate := fmt.Sprintf("%.1f%% (%d/%d)", sr.FlakeRate, sr.FailedRuns, sr.TotalRuns)
87 > if sr.FlakeRate > boldFlakeRateThreshold {
88 > rate = "**" + rate + "**"
89 > }
90 > sb.WriteString(fmt.Sprintf("| `%s` | %s | %s |\n", sr.SuiteName, rate, lastFailure))
91 }
92
93 > return sb.String() report.go
94 }
95