I wanted to test the code in my plugin that parses the Caddy file. However, how the parsing works is one gets a httpcaddyfile.Helper with just the contents of your module. I would need a way to mock this h httpcaddyfile.Helper with some sample Caddyfile configs for my plugin.
Is there anyway to do this? Any suggestions welcome!
The ideal solution would be a helper function that can take a partial Caddy file and turn it into a httpcaddyfile.Helper I could use to test against. I have not dug in enough to know if that is at all easy or hard…
Well - I got it work. But I had to refactor my caddyfileParser function to be able to call it with a Dispenser. This kind of makes the code a little weird - but not too bad.
It would be better if we could get a mock Helper like I can get the mock Dispenser.
However, it works and writing the tests certainly caused me to fix a couple of issues - so I very much recommend folks do this!