Skip to content

Commit bbd1b29

Browse files
committed
add empty test funcs
1 parent 36c168a commit bbd1b29

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

pkg/testcoverage/check_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@ func TestCheck(t *testing.T) {
265265
assert.Error(t, err)
266266
assert.Contains(t, err.Error(), "failed to load base coverage breakdown")
267267
})
268+
269+
t.Run("valid profile - diff pass", func(t *testing.T) {
270+
t.Parallel()
271+
// add test
272+
})
273+
274+
t.Run("valid profile - diff fail", func(t *testing.T) {
275+
t.Parallel()
276+
// add test
277+
})
268278
}
269279

270280
//nolint:paralleltest // must not be parallel because it uses env
@@ -450,6 +460,21 @@ func Test_Analyze(t *testing.T) {
450460
assert.False(t, result.Pass())
451461
assertPrefix(t, result, prefix, true)
452462
})
463+
464+
t.Run("diff stats", func(t *testing.T) {
465+
t.Parallel()
466+
// add test
467+
})
468+
469+
t.Run("diff below threshold", func(t *testing.T) {
470+
t.Parallel()
471+
// add test
472+
})
473+
474+
t.Run("diff above threshold", func(t *testing.T) {
475+
t.Parallel()
476+
// add test
477+
})
453478
}
454479

455480
func TestLoadBaseCoverageBreakdown(t *testing.T) {

pkg/testcoverage/helpers_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package testcoverage_test
33
import (
44
crand "crypto/rand"
55
"encoding/hex"
6+
"fmt"
67
"math/rand"
78
"os"
89
"strings"
@@ -193,6 +194,20 @@ func assertNoUncoveredLinesInfo(t *testing.T, content string) {
193194
assert.Empty(t, uncoveredReport)
194195
}
195196

197+
func assertDiffNoChange(t *testing.T, content string) {
198+
t.Helper()
199+
200+
assert.Contains(t, content, "No coverage changes in any files compared to the base")
201+
}
202+
203+
func assertDiffChange(t *testing.T, content string, lines int) {
204+
t.Helper()
205+
206+
//nolint:lll //relax
207+
str := fmt.Sprintf("Test coverage has changed in the current files, with %d lines missing coverage", lines)
208+
assert.Contains(t, content, str)
209+
}
210+
196211
func assertGithubActionErrorsCount(t *testing.T, content string, count int) {
197212
t.Helper()
198213

pkg/testcoverage/report_test.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func Test_ReportForHuman(t *testing.T) {
2525

2626
buf := &bytes.Buffer{}
2727
ReportForHuman(buf, AnalyzeResult{Threshold: thr, TotalStats: coverage.Stats{}})
28+
2829
assertHumanReport(t, buf.String(), 3, 0)
2930
assertNoUncoveredLinesInfo(t, buf.String())
3031
})
@@ -34,6 +35,7 @@ func Test_ReportForHuman(t *testing.T) {
3435

3536
buf := &bytes.Buffer{}
3637
ReportForHuman(buf, AnalyzeResult{Threshold: thr, TotalStats: coverage.Stats{Total: 1}})
38+
3739
assertHumanReport(t, buf.String(), 2, 1)
3840
assertNoUncoveredLinesInfo(t, buf.String())
3941
})
@@ -48,6 +50,7 @@ func Test_ReportForHuman(t *testing.T) {
4850
allStats := mergeStats(statsWithError, statsNoError)
4951
result := Analyze(cfg, allStats, nil)
5052
ReportForHuman(buf, result)
53+
5154
headReport, uncoveredReport := splitReport(t, buf.String())
5255
assertHumanReport(t, headReport, 0, 1)
5356
assertContainStats(t, headReport, statsWithError)
@@ -70,6 +73,7 @@ func Test_ReportForHuman(t *testing.T) {
7073
allStats := mergeStats(statsWithError, statsNoError)
7174
result := Analyze(cfg, allStats, nil)
7275
ReportForHuman(buf, result)
76+
7377
headReport, uncoveredReport := splitReport(t, buf.String())
7478
assertHumanReport(t, headReport, 0, 1)
7579
assertContainStats(t, headReport, MakePackageStats(statsWithError))
@@ -83,6 +87,12 @@ func Test_ReportForHuman(t *testing.T) {
8387
coverage.StatsPluckName(coverage.StatsFilterWithCoveredLines(allStats)),
8488
)
8589
})
90+
}
91+
92+
func Test_ReportForHumanDiff(t *testing.T) {
93+
t.Parallel()
94+
95+
const prefix = "organization.org"
8696

8797
t.Run("diff - no change", func(t *testing.T) {
8898
t.Parallel()
@@ -94,7 +104,7 @@ func Test_ReportForHuman(t *testing.T) {
94104
result := Analyze(cfg, stats, stats)
95105
ReportForHuman(buf, result)
96106

97-
assert.Contains(t, buf.String(), "No coverage changes in any files compared to the base")
107+
assertDiffNoChange(t, buf.String())
98108
})
99109

100110
t.Run("diff - has change", func(t *testing.T) {
@@ -113,16 +123,24 @@ func Test_ReportForHuman(t *testing.T) {
113123
result := Analyze(cfg, stats, base)
114124
ReportForHuman(buf, result)
115125

116-
assert.Contains(t, buf.String(),
117-
"Test coverage has changed in the current files, with 2 lines missing coverage",
118-
)
126+
assertDiffChange(t, buf.String(), 2)
127+
})
128+
129+
t.Run("diff - threshold failed", func(t *testing.T) {
130+
t.Parallel()
131+
// add test
132+
})
133+
134+
t.Run("diff - threshold pass", func(t *testing.T) {
135+
t.Parallel()
136+
// add test
119137
})
120138
}
121139

122140
func Test_ReportForGithubAction(t *testing.T) {
123141
t.Parallel()
124142

125-
prefix := "organization.org/pkg/"
143+
const prefix = "organization.org/pkg/"
126144

127145
t.Run("total coverage - pass", func(t *testing.T) {
128146
t.Parallel()

0 commit comments

Comments
 (0)