test: net: lib: prometheus: formatter: Fix test flakiness

If a string is already present in the provided buffer,
prometheus_format_exposition() appends it instead of overwriting,
hence the buffer needs to be cleared on the test start, otherwise it
works by chance.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2024-11-04 13:18:46 +01:00 committed by Dan Kalowsky
commit a597feafb8

View file

@ -36,7 +36,7 @@ PROMETHEUS_COLLECTOR_DEFINE(test_custom_collector);
ZTEST(test_formatter, test_prometheus_formatter_simple) ZTEST(test_formatter, test_prometheus_formatter_simple)
{ {
int ret; int ret;
char formatted[MAX_BUFFER_SIZE]; char formatted[MAX_BUFFER_SIZE] = { 0 };
struct prometheus_counter *counter; struct prometheus_counter *counter;
char exposed[] = "# HELP test_counter Test counter\n" char exposed[] = "# HELP test_counter Test counter\n"
"# TYPE test_counter counter\n" "# TYPE test_counter counter\n"