diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-10-01 12:50:29 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-10-02 09:40:02 +0000 |
| commit | e6185ff22b3ea7f1e80c8f931fbc21802df71402 (patch) | |
| tree | 7c02141b631d2de51a9274235512b20acb1f9283 /pkg/cover/heatmap_test.go | |
| parent | fb95da31ee52924519e703c1d8aa32bffe1db3e0 (diff) | |
pkg/cover: specify target commit requesting the line coverage
Diffstat (limited to 'pkg/cover/heatmap_test.go')
| -rw-r--r-- | pkg/cover/heatmap_test.go | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pkg/cover/heatmap_test.go b/pkg/cover/heatmap_test.go index f7c058a7a..5739d2e9c 100644 --- a/pkg/cover/heatmap_test.go +++ b/pkg/cover/heatmap_test.go @@ -35,7 +35,8 @@ func TestFilesCoverageToTemplateData(t *testing.T) { Filepath: "file1", Instrumented: 1, Covered: 1, - TimePeriod: coveragedb.TimePeriod{DateTo: civil.Date{Year: 2024, Month: time.July, Day: 1}, Days: 1}, + TimePeriod: makeTimePeriod(t, civil.Date{Year: 2024, Month: time.July, Day: 1}, coveragedb.DayPeriod), + Commit: "commit1", }, }, want: &templateHeatmap{ @@ -52,7 +53,7 @@ func TestFilesCoverageToTemplateData(t *testing.T) { "Instrumented:\t1 blocks\nCovered:\t1 blocks", }, FileCoverageLink: []string{ - "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit&filepath=file1"}, + "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit1&filepath=file1"}, }, }, Name: "", @@ -74,13 +75,15 @@ func TestFilesCoverageToTemplateData(t *testing.T) { Filepath: "dir/file2", Instrumented: 1, Covered: 0, - TimePeriod: coveragedb.TimePeriod{DateTo: civil.Date{Year: 2024, Month: time.July, Day: 2}, Days: 1}, + TimePeriod: makeTimePeriod(t, civil.Date{Year: 2024, Month: time.July, Day: 2}, coveragedb.DayPeriod), + Commit: "commit2", }, { Filepath: "dir/file1", Instrumented: 1, Covered: 1, - TimePeriod: coveragedb.TimePeriod{DateTo: civil.Date{Year: 2024, Month: time.July, Day: 1}, Days: 1}, + TimePeriod: makeTimePeriod(t, civil.Date{Year: 2024, Month: time.July, Day: 1}, coveragedb.DayPeriod), + Commit: "commit1", }, }, want: &templateHeatmap{ @@ -100,8 +103,8 @@ func TestFilesCoverageToTemplateData(t *testing.T) { "Instrumented:\t0 blocks\nCovered:\t0 blocks", }, FileCoverageLink: []string{ - "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit&filepath=dir/file1", - "/upstream/graph/coverage/file?dateto=2024-07-02&period=day&commit=commit&filepath=dir/file1"}, + "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit1&filepath=dir/file1", + "/upstream/graph/coverage/file?dateto=2024-07-02&period=day&commit=commit2&filepath=dir/file1"}, }, { Items: []*templateHeatmapRow{}, @@ -115,8 +118,8 @@ func TestFilesCoverageToTemplateData(t *testing.T) { "Instrumented:\t1 blocks\nCovered:\t0 blocks", }, FileCoverageLink: []string{ - "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit&filepath=dir/file2", - "/upstream/graph/coverage/file?dateto=2024-07-02&period=day&commit=commit&filepath=dir/file2"}, + "/upstream/graph/coverage/file?dateto=2024-07-01&period=day&commit=commit1&filepath=dir/file2", + "/upstream/graph/coverage/file?dateto=2024-07-02&period=day&commit=commit2&filepath=dir/file2"}, }, }, Name: "dir", @@ -150,3 +153,9 @@ func TestFilesCoverageToTemplateData(t *testing.T) { }) } } + +func makeTimePeriod(t *testing.T, targetDate civil.Date, periodType string) coveragedb.TimePeriod { + tp, err := coveragedb.MakeTimePeriod(targetDate, periodType) + assert.NoError(t, err) + return tp +} |
