Skip to content

Commit

Permalink
Merge pull request #10 from mcubik/issue/1-fix-missing-points
Browse files Browse the repository at this point in the history
Fix missing points in total values
  • Loading branch information
mcubik committed Aug 17, 2019
2 parents b9553c3 + c6b6937 commit d33b5ae
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 1,114 deletions.
26 changes: 13 additions & 13 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,33 @@ func TestEmptyConfigWhenFileMissing(t *testing.T) {
func TestThreshold(t *testing.T) {
assert := assert.New(t)
summary := report.Summary{BlockCoverage: 79.9, StmtCoverage: 82.3}
res, err := checkThreshold(80, summary, "block")
passed, err := checkThreshold(80, summary, "block")
assert.NoError(err)
assert.False(res)
assert.False(passed)

res, err = checkThreshold(79, summary, "block")
passed, err = checkThreshold(79, summary, "block")
assert.NoError(err)
assert.True(res)
assert.True(passed)

res, err = checkThreshold(79.9, summary, "block")
passed, err = checkThreshold(79.9, summary, "block")
assert.NoError(err)
assert.True(res)
assert.True(passed)

res, err = checkThreshold(82, summary, "stmt")
passed, err = checkThreshold(82, summary, "stmt")
assert.NoError(err)
assert.True(res)
assert.True(passed)

}

func TestNoThreshold(t *testing.T) {
assert := assert.New(t)
summary := report.Summary{BlockCoverage: 79.9, StmtCoverage: 82.3}
res, err := checkThreshold(0, summary, "block")
passed, err := checkThreshold(0, summary, "block")
assert.NoError(err)
assert.True(res)
assert.True(passed)
}

func TestInvalidTresholdType(t *testing.T) {
func TestInvalidMetric(t *testing.T) {
assert := assert.New(t)
summary := report.Summary{BlockCoverage: 79.9, StmtCoverage: 82.3}
_, err := checkThreshold(80, summary, "xxxx")
Expand All @@ -81,15 +81,15 @@ func TestRun(t *testing.T) {
assert := assert.New(t)
args := arguments{
coverprofile: "sample_coverage.out",
threshold: 80,
threshold: 82,
metric: "block",
sortBy: "filename",
order: "asc"}
buf := bytes.Buffer{}
passed, err := run(configuration{}, args, &buf)
assert.NoError(err)
assert.False(passed)
assert.Contains(buf.String(), "TOTAL", "Table generated")
assert.Contains(buf.String(), "Total", "Table generated")
}

func TestRunAboveThreshold(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions report/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func TestReport(t *testing.T) {
assert := assert.New(t)
report, err := GenerateReport("../sample_coverage.out", "", []string{}, "block", "desc")
assert.NoError(err)
assert.InDelta(75.6, report.Total.BlockCoverage, 0.1)
assert.InDelta(80, report.Total.StmtCoverage, 0.1)
assert.Equal(1801, report.Total.Stmts)
assert.Equal(1097, report.Total.Blocks)
assert.InDelta(81.4, report.Total.BlockCoverage, 0.1)
assert.InDelta(81.9, report.Total.StmtCoverage, 0.1)
assert.Equal(111, report.Total.Stmts)
assert.Equal(81, report.Total.Blocks)
}

func TestInvalidCoverProfile(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions report/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func PrintTable(report Report, writer io.Writer) {
for _, fileCoverage := range report.Files {
table.Append(makeRow(fileCoverage))
}
table.SetAutoFormatHeaders(false)
table.SetFooter(makeRow(report.Total))
table.Render()
}
Expand Down
Loading

0 comments on commit d33b5ae

Please sign in to comment.