Skip to content

test: add misc. tests to improve coverage#673

Merged
nfischer merged 1 commit intomasterfrom
test-add-missing-cases
Mar 5, 2017
Merged

test: add misc. tests to improve coverage#673
nfischer merged 1 commit intomasterfrom
test-add-missing-cases

Conversation

@nfischer
Copy link
Copy Markdown
Member

No change in production logic.

This adds missing tests to improve test coverage. This does not change
ShellJS behavior at all--all test cases are testing already-working
functionality.

One test case has been renamed for clarity.

For the "omit directory if missing recursive flag" case, we were
actually already testing that in another case, but we were testing
multiple things in that test case. It's better to test this one error
condition explicitly in its own case.

When adding real tests for parseOptions(), we need to explicitly clear
common.state.error because we're testing an internal function, not a
wrapped command.

Partial fix for #671

@nfischer nfischer added the test label Feb 26, 2017
@nfischer nfischer requested a review from freitagbr February 26, 2017 22:17

test('-nR does not overwrite an existing file at the destination', t => {
// Create tmp/new/cp/a
const dest = `${t.context.tmp}/new/cp`;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should be using path.join to join paths everywhere, but its probably not an issue for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it looks like one of the mv tests failed on windows for this exact reason. Maybe we should create another issue for this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShellJS should be able to handle paths using /, regardless of which platform we're on

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, looks like we caught a bug. We should probably be converting the output to use a / instead of a \.

No change in production logic.

This adds missing tests to improve test coverage. This does not change
ShellJS behavior at all--all test cases are testing already-working
functionality.

One test case has been renamed for clarity.

For the "omit directory if missing recursive flag" case, we were
actually already testing that in another case, but we were testing
multiple things in that test case. It's better to test this one error
condition explicitly in its own case.

When adding real tests for `parseOptions()`, we need to explicitly clear
`common.state.error` because we're testing an internal function, not a
wrapped command.

Partial fix for #671
@nfischer nfischer force-pushed the test-add-missing-cases branch from 2d02479 to 34124cd Compare March 5, 2017 09:12
@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 5, 2017

Codecov Report

Merging #673 into master will increase coverage by 0.85%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #673      +/-   ##
==========================================
+ Coverage   92.68%   93.53%   +0.85%     
==========================================
  Files          33       33              
  Lines        1176     1176              
==========================================
+ Hits         1090     1100      +10     
+ Misses         86       76      -10
Impacted Files Coverage Δ
src/cp.js 90.09% <0%> (+1.8%)
src/rm.js 100% <0%> (+2.12%)
src/common.js 96.62% <0%> (+2.24%)
src/mv.js 97.29% <0%> (+5.4%)
src/toEnd.js 100% <0%> (+9.09%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 346fca4...34124cd. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants