https://pantsbuild.org/ logo
#development
Title
# development
b

bored-art-40741

04/10/2021, 11:57 PM
Another testing question: is there an easy way to mock the behavior of a
Process
invocation that I know my rule is going to make?
e

enough-analyst-54434

04/10/2021, 11:58 PM
I'm not sure besides stitching in a rule to go Process -> <forget the return type> to take the place of the ~build-in rule.
RuleRunner.replace(Input, Output, @rule) might be handy if it existed. I'm pretty sure this is not easy today.
You can mock Gets somewhere though ...
b

bored-art-40741

04/11/2021, 12:01 AM
Mocking Gets would probably be fine as long as I had the ability to selectively return a result for only the Get I care about
e

enough-analyst-54434

04/11/2021, 12:02 AM
I think you must ock them all.
Basically you need to provide an input for every edge into your @rule under test.
b

bored-art-40741

04/11/2021, 12:05 AM
Hmmm, seems like we could either check a caller-provided matching predicate against
subject
here, and then fall back to a "real" rule graph if nothing matched
But realistically I suppose I don't need that, I can just stick to precisely unit testing rules that make the
Process
calls I care about. Their direct dependencies shouldn't be hard to mock in