diff options
| author | Taras Madan <tarasmadan@google.com> | 2025-01-23 21:54:41 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2025-01-27 10:05:21 +0000 |
| commit | 2bf68614de1620ef12f086d9e86d5c8b334bf32d (patch) | |
| tree | 24b69669a1ee44c1a34988d917cb248faed40cd3 /pkg/cover/heatmap.go | |
| parent | 0868754a9d325ba9011e1cb74510f68d4b627c79 (diff) | |
dashboard/app: test coverage /file link
1. Init coveragedb client once and propagate it through context to enable mocking.
2. Always init coverage handlers. It simplifies testing.
3. Read webGit and coveragedb client from ctx to make it mockable.
4. Use int for file line number and int64 for merged coverage.
5. Add tests.
Diffstat (limited to 'pkg/cover/heatmap.go')
| -rw-r--r-- | pkg/cover/heatmap.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/cover/heatmap.go b/pkg/cover/heatmap.go index 04b7e6914..4cc212fad 100644 --- a/pkg/cover/heatmap.go +++ b/pkg/cover/heatmap.go @@ -116,13 +116,13 @@ type fileCoverageWithDetails struct { Subsystems []string } -type fileCoverageWithLineInfo struct { +type FileCoverageWithLineInfo struct { fileCoverageWithDetails LinesInstrumented []int64 HitCounts []int64 } -func (fc *fileCoverageWithLineInfo) CovMap() map[int]int64 { +func (fc *FileCoverageWithLineInfo) CovMap() map[int]int64 { return MakeCovMap(fc.LinesInstrumented, fc.HitCounts) } @@ -223,12 +223,12 @@ func readCoverage(iterManager spannerclient.RowIterator) ([]*fileCoverageWithDet func readCoverageUniq(full, mgr spannerclient.RowIterator, ) ([]*fileCoverageWithDetails, error) { eg, ctx := errgroup.WithContext(context.Background()) - fullCh := make(chan *fileCoverageWithLineInfo) + fullCh := make(chan *FileCoverageWithLineInfo) eg.Go(func() error { defer close(fullCh) return readIterToChan(ctx, full, fullCh) }) - partCh := make(chan *fileCoverageWithLineInfo) + partCh := make(chan *FileCoverageWithLineInfo) eg.Go(func() error { defer close(partCh) return readIterToChan(ctx, mgr, partCh) @@ -309,7 +309,7 @@ func UniqCoverage(fullCov, partCov map[int]int64) map[int]int64 { return res } -func readIterToChan[K fileCoverageWithLineInfo | fileCoverageWithDetails]( +func readIterToChan[K FileCoverageWithLineInfo | fileCoverageWithDetails]( ctx context.Context, iter spannerclient.RowIterator, ch chan<- *K) error { for { row, err := iter.Next() |
