Skip to content

Commit

Permalink
Improve code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins committed Sep 15, 2020
1 parent e5c0294 commit a75c421
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
node-version: "14.x"
- run: npm ci
- run: npm test
- run: npm run test:coverage
- name: Report Tachometer Result
uses: ./
with:
Expand All @@ -31,7 +31,7 @@ jobs:
with:
node-version: "14.x"
- run: npm ci
- run: npm test
- run: npm run test:coverage
- name: Report Other Tachometer Result
uses: andrewiggins/tachometer-reporter-action@master
with:
Expand Down
6 changes: 6 additions & 0 deletions dist/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -14035,6 +14035,7 @@ function getStateName(state) {
return state;
} else {
const keys = Object.keys(state);
/* c8 ignore next 3 */
if (keys.length !== 1) {
throw new Error(`Unexpected state shape object returned: ${state}`);
}
Expand Down Expand Up @@ -14431,6 +14432,7 @@ async function acquireCommentLock(github, context, getInitialBody, logger) {
break;
}

/* c8 ignore next 2 */
default:
throw new Error(`Unexpected stateName: ${JSON.stringify(stateName)}`);
}
Expand Down Expand Up @@ -14515,6 +14517,7 @@ async function readComment(github, context, logger) {
}
}
}
/* c8 ignore next 4 */
} catch (e) {
logger.warn("Error trying to read comments: " + e.message);
logger.debug(() => e.toString());
Expand All @@ -14531,6 +14534,7 @@ async function readComment(github, context, logger) {
* @returns {Promise<import('./global').CommentData>}
*/
async function updateComment(github, context, body, logger) {
/* c8 ignore next 3 */
if (context.commentId == null) {
throw new Error(`Cannot update comment if "context.commentId" is null`);
}
Expand Down Expand Up @@ -14616,6 +14620,8 @@ async function postOrUpdateComment(github, context, getCommentBody, logger) {
try {
const body = getFinalBody(context, getCommentBody, comment);
comment = await updateComment(github, context, body, logger);

/* c8 ignore next 4 */
} catch (e) {
logger.info(`Error updating comment: ${e.message}`);
logger.debug(() => e.toString());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:index": "sucrase --production -t jsx --jsx-pragma h -d lib ./src",
"build:action": "rollup -c ./rollup.config.js",
"test": "uvu tests",
"test:coverage": "c8 --reporter=html --reporter=text npm test"
"test:coverage": "c8 --check-coverage --statements 100 --reporter=html --reporter=text npm test"
},
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions src/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function getStateName(state) {
return state;
} else {
const keys = Object.keys(state);
/* c8 ignore next 3 */
if (keys.length !== 1) {
throw new Error(`Unexpected state shape object returned: ${state}`);
}
Expand Down Expand Up @@ -457,6 +458,7 @@ async function acquireCommentLock(github, context, getInitialBody, logger) {
break;
}

/* c8 ignore next 2 */
default:
throw new Error(`Unexpected stateName: ${JSON.stringify(stateName)}`);
}
Expand Down Expand Up @@ -541,6 +543,7 @@ async function readComment(github, context, logger) {
}
}
}
/* c8 ignore next 4 */
} catch (e) {
logger.warn("Error trying to read comments: " + e.message);
logger.debug(() => e.toString());
Expand All @@ -557,6 +560,7 @@ async function readComment(github, context, logger) {
* @returns {Promise<import('./global').CommentData>}
*/
async function updateComment(github, context, body, logger) {
/* c8 ignore next 3 */
if (context.commentId == null) {
throw new Error(`Cannot update comment if "context.commentId" is null`);
}
Expand Down Expand Up @@ -642,6 +646,8 @@ async function postOrUpdateComment(github, context, getCommentBody, logger) {
try {
const body = getFinalBody(context, getCommentBody, comment);
comment = await updateComment(github, context, body, logger);

/* c8 ignore next 4 */
} catch (e) {
logger.info(`Error updating comment: ${e.message}`);
logger.debug(() => e.toString());
Expand Down
4 changes: 2 additions & 2 deletions tests/results/multi-measure-no-names.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
{
"absolute": {
"low": 2.303351653674162,
"low": 0,
"high": 4.610315012993788
},
"percentChange": {
Expand Down Expand Up @@ -434,7 +434,7 @@
{
"absolute": {
"low": -4.610315012993788,
"high": -2.303351653674162
"high": 0
},
"percentChange": {
"low": -20.522852558105033,
Expand Down

0 comments on commit a75c421

Please sign in to comment.