-
-
Couldn't load subscription status.
- Fork 3
Add comprehensive tests for utils.R and improve coverage for low-coverage files #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…eve 100% coverage Co-authored-by: rempsyc <[email protected]>
…mp version to 0.2.1.2 Co-authored-by: rempsyc <[email protected]>
get_dep_version())|
@copilot thanks, I see the following errors: ══ Failed tests ════════════════════════════════════════════════════════════════
── Error ('test-nice_modindices.R:71:3'): nice_modindices without labels ───────
Error: Error: Package `sjlabelled` required for this function to work.
Please install it by running `install.packages("sjlabelled")`.And make sure to redocument, fix lints, style, etc. |
…cefully Co-authored-by: rempsyc <[email protected]>
... Fixed the test failures by making the |
R/nice_modindices.R
Outdated
| labels <- sjlabelled::get_label(dat) | ||
| if (all(labels == "")) { | ||
| labels <- NULL | ||
| if (requireNamespace("sjlabelled", quietly = TRUE)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot In fact, we don't want to run it conditionally here, because we always want to extract the labels this way when it is not provided manually. Instead, what we want to do, is to add a skip check in the corresponding test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I've reverted the nice_modindices function to its original state (keeping insight::check_if_installed("sjlabelled")) and instead added skip_if_not_installed("sjlabelled") checks to the three failing tests. This preserves the intended behavior of always extracting labels when not provided manually, while making tests skip gracefully when the package isn't available. All tests now pass: 89 PASS, 0 FAIL, 40 SKIP. Commit: 7cbf067
… to tests Co-authored-by: rempsyc <[email protected]>
Fixed Issues
nice_modindices Function Fix
sjlabelledpackage was not availableskip_if_not_installed("sjlabelled")checks to relevant tests while keeping the original function behaviorChanges Made
tests/testthat/test-nice_modindices.R:nice_modindices without labelsnice_modindices with sort = FALSEnice_modindices with additional lavaan parametersR/nice_modindices.Rin its original state withinsight::check_if_installed("sjlabelled")devtools::document()The function properly requires
sjlabelledwhen labels need to be extracted automatically, while tests skip gracefully when the package is not available. This maintains the intended behavior while preventing test failures in environments without optional packages.Fixes the test errors mentioned in PR comments.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.