Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
👋
I would like to propose additional function to
testutil.go
which will count metrics in a given Collector. The example usage can be seen here: https://github.com/thanos-io/thanos/blob/d758432436718ff6cd0d9136bc53653f4ec5cf47/pkg/compact/compact_e2e_test.go#L179I also read the package documentation and I think I can agree that mock would be preferred for all of those test assertions IF such mock would be ready to use somewhere AND it would be easy to inject those mocked counter, gauges etc. The latter might be even impossible given the
*Vec
metrics are not interfaces e.g:Overall I think, with this small function
testutil
gives all you need to unit test your instrumentation without mocks, except maybe registering part, which is easier to mock.Signed-off-by: Bartlomiej Plotka bwplotka@gmail.com