r0gue-io / pop-cli

An all-in-one tool for Polkadot development.
GNU General Public License v3.0
74 stars 21 forks source link

test: use module CLI in all commands and add unit test in pop-cli crate #315

Open AlexD10S opened 2 months ago

AlexD10S commented 2 months ago

This PR refactors all pop-cli commands to use the CLI module introduce in this PR https://github.com/r0gue-io/pop-cli/pull/216, enabling us to test the output messages produced by the CLI. Additionally, tests have been added to ensure better coverage in the pop-cli crate. As a result, the test coverage of pop-clihas increased significantly, from 34% to 67% with overall project coverage now nearing our goal: 80%.

Coverage still can be improved, particularly the final parts of the install, build, and up commands, which are difficult to mock for a unit test.

Note: The call command does not include tests because they are being addressed in parallel in this PR https://github.com/r0gue-io/pop-cli/pull/306 to avoid duplication of work.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 76.47368% with 447 lines in your changes missing coverage. Please review.

Project coverage is 78.09%. Comparing base (582db18) to head (b13a70c). Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
crates/pop-cli/src/commands/up/parachain.rs 63.00% 82 Missing and 29 partials :warning:
crates/pop-cli/src/commands/up/contract.rs 61.63% 65 Missing and 24 partials :warning:
crates/pop-cli/src/cli.rs 53.01% 73 Missing and 5 partials :warning:
crates/pop-cli/src/commands/install/mod.rs 76.77% 18 Missing and 18 partials :warning:
crates/pop-cli/src/commands/new/parachain.rs 92.28% 3 Missing and 20 partials :warning:
crates/pop-cli/src/commands/build/spec.rs 92.76% 3 Missing and 19 partials :warning:
crates/pop-cli/src/commands/new/contract.rs 84.28% 3 Missing and 19 partials :warning:
crates/pop-cli/src/commands/test/contract.rs 70.31% 8 Missing and 11 partials :warning:
crates/pop-cli/src/commands/new/pallet.rs 85.52% 4 Missing and 7 partials :warning:
crates/pop-cli/src/common/helpers.rs 87.50% 0 Missing and 8 partials :warning:
... and 7 more
@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
+ Coverage   70.32%   78.09%   +7.77%     
==========================================
  Files          53       54       +1     
  Lines        9098    10387    +1289     
  Branches     9098    10387    +1289     
==========================================
+ Hits         6398     8112    +1714     
+ Misses       1718     1110     -608     
- Partials      982     1165     +183     
Files with missing lines Coverage Δ
...op-parachains/src/new_pallet/new_pallet_options.rs 0.00% <0.00%> (ø)
crates/pop-cli/src/commands/mod.rs 16.00% <0.00%> (-0.33%) :arrow_down:
crates/pop-contracts/src/node/mod.rs 64.44% <50.00%> (ø)
crates/pop-contracts/src/call.rs 80.45% <76.19%> (+1.83%) :arrow_up:
crates/pop-contracts/src/init_tests.rs 66.66% <66.66%> (ø)
crates/pop-cli/src/common/contracts.rs 52.85% <77.77%> (+52.85%) :arrow_up:
crates/pop-contracts/src/up.rs 80.00% <77.41%> (+2.34%) :arrow_up:
crates/pop-cli/src/common/helpers.rs 86.15% <87.50%> (+86.15%) :arrow_up:
crates/pop-cli/src/commands/new/pallet.rs 75.67% <85.52%> (+59.26%) :arrow_up:
crates/pop-cli/src/commands/test/contract.rs 61.33% <70.31%> (+61.33%) :arrow_up:
... and 7 more

... and 7 files with indirect coverage changes