KEMBAR78
Refactor Check unit tests by mc1098 · Pull Request #421 · dotenv-linter/dotenv-linter · GitHub
Skip to content

Conversation

@mc1098
Copy link
Contributor

@mc1098 mc1098 commented Apr 19, 2021

Refactors the unit tests for Check implementations as per #419.

Unit tests have been replaced with a new check_tester macro which takes care of the boiler plate of writing multiple test cases. This would make the tests easier to change when an interface change is required, such as #410, as only the expanded code of the macro is changed to reflect the new API.

This change would also effect #414 and once that PR is merged I'm happy to make the changes so that it is included in this refactoring :)

Closes #419

✔ Checklist:

@mc1098 mc1098 force-pushed the check_test_macro branch from 1d06e83 to 990b095 Compare April 19, 2021 10:39
@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2021

Codecov Report

Merging #421 (7d6bc55) into master (889636e) will decrease coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #421      +/-   ##
==========================================
- Coverage   99.01%   98.97%   -0.05%     
==========================================
  Files          38       38              
  Lines        2746     2634     -112     
==========================================
- Hits         2719     2607     -112     
  Misses         27       27              
Impacted Files Coverage Δ
src/checks.rs 100.00% <ø> (ø)
src/checks/duplicated_key.rs 100.00% <100.00%> (ø)
src/checks/ending_blank_line.rs 100.00% <100.00%> (ø)
src/checks/extra_blank_line.rs 100.00% <100.00%> (ø)
src/checks/incorrect_delimiter.rs 100.00% <100.00%> (ø)
src/checks/key_without_value.rs 100.00% <100.00%> (ø)
src/checks/leading_character.rs 100.00% <100.00%> (ø)
src/checks/lowercase_key.rs 100.00% <100.00%> (ø)
src/checks/quote_character.rs 100.00% <100.00%> (ø)
src/checks/space_character.rs 100.00% <100.00%> (ø)
... and 6 more

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 889636e...7d6bc55. Read the comment docs.

@mc1098 mc1098 force-pushed the check_test_macro branch from 990b095 to 3d88c8c Compare April 19, 2021 13:40
@mc1098
Copy link
Contributor Author

mc1098 commented Apr 19, 2021

I've just updated this PR to take into account the recently merged #414 🎉

@mgrachev
Copy link
Member

@mc1098 👋 Thank you for your contribution 👍

Sorry, I'm quite busy now, so I'll try to review your PR by the end of the week 🙁

@mgrachev mgrachev requested a review from a team April 20, 2021 11:53
@mgrachev mgrachev added this to the v3.1.0 milestone Apr 20, 2021
mc1098 added 4 commits April 20, 2021 21:42
check_tester macro helps to remove the boiler plate when testing the
impls of the Check trait.
Internal documentation for the check_tester macro to make it
easier to understand and use with some examples.
Refactors SubstitutionKeyChecker unit tests to use the check_tester
macro inline with the other Check impls.
@mc1098 mc1098 force-pushed the check_test_macro branch from 3d88c8c to 5b362f8 Compare April 20, 2021 20:45
mc1098 added 2 commits April 29, 2021 02:29
Replaces the check_tester! declarative macro with a generic test
helper function. This will be more explicit and easier to update
than the check_tester macro.
DDtKey
DDtKey previously approved these changes Apr 29, 2021
Copy link
Member

@DDtKey DDtKey left a comment

Choose a reason for hiding this comment

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

Thank you for the great job! 🚀

@DDtKey DDtKey mentioned this pull request Apr 29, 2021
3 tasks
mgrachev
mgrachev previously approved these changes May 8, 2021
@mgrachev
Copy link
Member

mgrachev commented May 8, 2021

@mc1098 Please add your changes to the CHANGELOG.md file 🙂

Updates the changelog to include the changes made in the PR dotenv-linter#421.
@mc1098 mc1098 dismissed stale reviews from mgrachev and DDtKey via 699e9e8 May 8, 2021 13:26
@mc1098 mc1098 changed the title Check test macro Refactor Check unit tests May 8, 2021
mgrachev
mgrachev previously approved these changes May 8, 2021
Fixes the 'inconsistent-struct-constructor' clippy warning.
@mgrachev mgrachev merged commit dd98c04 into dotenv-linter:master May 8, 2021
@mgrachev
Copy link
Member

mgrachev commented May 8, 2021

@mc1098 Thank you for your help 🔥

🙏 If it’s not difficult for you, please support the project - star on GitHub ⭐️

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Check impl unit testing

4 participants