write_prometheus_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMICROHTTPD_CPPFLAGS)
write_prometheus_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMICROHTTPD_LDFLAGS)
write_prometheus_la_LIBADD = $(BUILD_WITH_LIBMICROHTTPD_LIBS)
+
+test_plugin_write_prometheus_SOURCES = src/write_prometheus_test.c \
+ src/write_prometheus.c
+test_plugin_write_prometheus_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBMICROHTTPD_CPPFLAGS)
+test_plugin_write_prometheus_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBMICROHTTPD_LDFLAGS)
+test_plugin_write_prometheus_LDADD = libplugin_mock.la libavltree.la \
+ $(BUILD_WITH_LIBMICROHTTPD_LIBS)
+check_PROGRAMS += test_plugin_write_prometheus
+TESTS += test_plugin_write_prometheus
endif
if BUILD_PLUGIN_WRITE_REDIS
--- /dev/null
+/**
+ * collectd - src/write_prometheus_test.c
+ * Copyright (C) 2023 Florian octo Forster
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Florian octo Forster <octo at collectd.org>
+ */
+
+#include "collectd.h"
+
+#include "testing.h"
+#include "daemon/metric.h"
+
+void format_metric_family(strbuf_t *buf, metric_family_t const *prom_fam);
+
+DEF_TEST(format_metric_family) {
+ strbuf_t got = STRBUF_CREATE;
+
+ metric_family_t fam = {
+ .name = "unit.test",
+ };
+
+ format_metric_family(&got, &fam);
+ EXPECT_EQ_INT(0, got.pos);
+
+ STRBUF_DESTROY(got);
+ return 0;
+}
+
+int main(void) {
+ RUN_TEST(format_metric_family);
+
+ END_TEST;
+}