Skip to content

Commit 9133ee0

Browse files
Vishal VaibhavGitHub Enterprise
authored andcommitted
detailed info on pr comments (#16)
1 parent da8b89f commit 9133ee0

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

internal/plugin/reporter/github_pr.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ func (s *GithubPullRequest) createCommentBody(changedLinesWithCoverage domain.So
9595
totalLines := linesWithDataCount + linesWithoutDataCount
9696
totalInstructions := covered + missed
9797

98-
result := make([]string, 3)
98+
result := make([]string, 5)
9999

100-
result[0] = fmt.Sprint("Code Coverage Summary:\n\n")
101-
result[1] = fmt.Sprintf("Lines With Coverage Data -> %.f%% (%d)\n", toPercent(safeDiv(float32(linesWithDataCount), float32(totalLines), 1)), linesWithDataCount)
102-
result[2] = fmt.Sprintf("Covered Instructions -> **%.f%%** (%d)\n", toPercent(safeDiv(float32(covered), float32(totalInstructions), 1)), covered)
100+
result[0] = fmt.Sprintf("Code Coverage Summary:\n\n")
101+
result[1] = fmt.Sprintf("Lines Without Coverage Data -> %.f%% (%d)\n", toPercent(safeDiv(float32(linesWithoutDataCount), float32(totalLines), 0)), linesWithoutDataCount)
102+
result[2] = fmt.Sprintf("Lines With Coverage Data -> %.f%% (%d)\n", toPercent(safeDiv(float32(linesWithDataCount), float32(totalLines), 1)), linesWithDataCount)
103+
result[3] = fmt.Sprintf("Covered Instructions -> **%.f%%** (%d)\n", toPercent(safeDiv(float32(covered), float32(totalInstructions), 1)), covered)
104+
result[4] = fmt.Sprintf("Missed Instructions -> %.f%% (%d)\n", toPercent(safeDiv(float32(missed), float32(totalInstructions), 0)), missed)
103105

104106
return result
105107
})...)

internal/plugin/runner_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ Missed Instructions -> 3% (5)
113113
requestAsserter.AssertRequestWasMade(t, "/api/v3/repos/some_org/some_repo/issues/123/comments", "SOME_API_KEY", map[string]interface{}{
114114
"body": `Code Coverage Summary:
115115
116+
Lines Without Coverage Data -> 92% (2216)
116117
Lines With Coverage Data -> 8% (182)
117118
Covered Instructions -> **97%** (177)
119+
Missed Instructions -> 3% (5)
118120
`,
119121
})
120122

@@ -166,8 +168,10 @@ Missed Instructions -> 3% (5)
166168
requestAsserter.AssertRequestWasMade(t, "/api/v3/repos/some_org/some_repo/issues/123/comments", "SOME_API_KEY", map[string]interface{}{
167169
"body": `Code Coverage Summary:
168170
171+
Lines Without Coverage Data -> 92% (2216)
169172
Lines With Coverage Data -> 8% (182)
170173
Covered Instructions -> **97%** (177)
174+
Missed Instructions -> 3% (5)
171175
`,
172176
})
173177

@@ -212,8 +216,10 @@ Missed Instructions -> 27% (3)
212216
213217
Code Coverage Summary:
214218
219+
Lines Without Coverage Data -> 78% (7)
215220
Lines With Coverage Data -> 22% (2)
216221
Covered Instructions -> **73%** (8)
222+
Missed Instructions -> 27% (3)
217223
`,
218224
})
219225

@@ -269,8 +275,10 @@ Missed Instructions -> 27% (3)
269275
270276
Code Coverage Summary:
271277
278+
Lines Without Coverage Data -> 78% (7)
272279
Lines With Coverage Data -> 22% (2)
273280
Covered Instructions -> **73%** (8)
281+
Missed Instructions -> 27% (3)
274282
`,
275283
})
276284

@@ -318,8 +326,10 @@ Missed Instructions -> 12% (6)
318326
319327
Code Coverage Summary:
320328
329+
Lines Without Coverage Data -> 47% (7)
321330
Lines With Coverage Data -> 53% (8)
322331
Covered Instructions -> **88%** (42)
332+
Missed Instructions -> 12% (6)
323333
`,
324334
})
325335

@@ -379,8 +389,10 @@ Missed Instructions -> 12% (6)
379389
380390
Code Coverage Summary:
381391
392+
Lines Without Coverage Data -> 47% (7)
382393
Lines With Coverage Data -> 53% (8)
383394
Covered Instructions -> **88%** (42)
395+
Missed Instructions -> 12% (6)
384396
`,
385397
})
386398

0 commit comments

Comments
 (0)