-
Notifications
You must be signed in to change notification settings - Fork 4
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
test: use function factory instead of {mockery} #207
Conversation
I must say I still have trouble wrapping my head around function factories 🤯 |
Codecov ReportAll modified and coverable lines are covered by tests ✅ |
@@ -1,9 +1,19 @@ | |||
test_that("user_categorisation works with valid input", { | |||
# create a mock object that returns user inputs in sequence | |||
mock_readline <- mockery::mock("3", "This is a note", "n") | |||
mock_factory <- function(...) { |
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.
the ellipsis is actually probably not needed here 🤔
@RayStick see also r-lib/testthat#1265 (comment) -- maybe you could define such a function in a helper file ( This way you could already drop mockery. |
@maelle thanks for your work on this! I am struggling to get my head around it at the moment |
Ah - think I got it! Working on it this morning |
The PR to testthat is making progress, so hopefully in a little while you can use that function (and have mapmetadata depend on the dev version of testthat) r-lib/testthat#2061 |
It's really nice especially with the explaining comments. |
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.
Thanks @maelle
@all-contributors add @maelle for code |
I've put up a pull request to add @maelle! 🎉 |
Reference: https://adv-r.hadley.nz/function-factories.html#factory-fundamentals
Created on 2025-02-19 with reprex v2.1.1