c7c7509669
* testutil compareMetricFamilies: make less error-prone The functions `GatherAndCompare`, `ScrapeAndCompare` and others that use `compareMetricFamilies` under the hood can return no error if `metricNames` includes none of the names found in the scraped/gathered results. To avoid false Positves (an error being the negative case), we can return an error if there is is at least one name in `metricNames` that is not in the filtered results. Fixes: https://github.com/prometheus/client_golang/issues/1351 Signed-off-by: leonnicolas <leonloechner@gmx.de> * Add missing metricNames to error In to see which metric names are missing, we can add them to the error message. Signed-off-by: leonnicolas <leonloechner@gmx.de> * Apply suggestions from code review - remove if nil check - use two nested loops instead of map - use new function `hasMetricByName` for readability Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> Signed-off-by: leonnicolas <60091705+leonnicolas@users.noreply.github.com> * prometheus/testutil/testutil_test.go: compare complete error Before we would only compare the error prefix in `TestScrapeAndCompare`. Signed-off-by: leonnicolas <leonloechner@gmx.de> --------- Signed-off-by: leonnicolas <leonloechner@gmx.de> Signed-off-by: leonnicolas <60091705+leonnicolas@users.noreply.github.com> Co-authored-by: Bartlomiej Plotka <bwplotka@gmail.com> |
||
---|---|---|
.. | ||
diff | ||
promlint | ||
lint.go | ||
lint_test.go | ||
testutil.go | ||
testutil_test.go |