add unit tests and minor fixes for resolveCollectorRefs()#220
add unit tests and minor fixes for resolveCollectorRefs()#220burningalchemist merged 2 commits intoburningalchemist:masterfrom hhromic:fix-rescollrefs
resolveCollectorRefs()#220Conversation
* return non-globbed resolved collectors in the order they are found * do not error when no collectors are resolved
|
Hey @hhromic, thanks heaps for the fix and introducing tests - this is a memorable event! 🚀 I plan to refactor the code, but before that a good test coverage is a must. So you definitely improved my motivation. 😃 Thanks again and no worries about the issue. 🙂👍 |
I fully understand what it is to be unmotivated, so I'm glad you feel more motivated!
Happy to help. I still have pending to implement configuration via env variables :) :) |
After my shameful programming errors in PR #194, some of them reported in #210 and fixed in #208, I decided to shield the codebase a bit against this type of mistakes by adding unit tests for the
resolveCollectorRefs()function. In particular:NoGlobbingtest: checks that non-globbed collector references are correctly resolved.Globbingtest: checks that globbed collector references are correctly resolved.NoCollectorRefstest: checks thatresolveCollectorRefs()resolves to empty when no collector references are given.UnknownCollectortest: checks thatresolveCollectorRefs()errors correctly when a collector reference is invalid.All of the above tests (with the exception of
Globbing) pass with the implementation in0.9.3(before globbing support).Only the
NoCollectorRefstest passes with the implementation in0.10.0(after globbing support => apologies again!).The
NoCollectorRefsandUnknownCollectortests do not pass with the implementation inmaster(after the fix in #208). TheNoGlobbingtest passes/fails in a non-deterministic manner becauseresolveCollectorRefs()no longer returns the resolved collectors in the same order as in0.9.3. Note that order does not really matter, but still wanted to stay correct.All of the above is now also fixed in a second commit in this PR, bringing
resolveCollectorRefs()to its previous behaviour when not using globbing patterns in collector references:The
Makefileand the GitHubbuild.ymlworkflow in the project already have testing support, so all of this will be automatically executed in future PRs/commits. For example:Local machine:
GitHub workflow:

I hope this helps to avoid these silly mistakes in future contributions :)
--
fixes #210