diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2026-08-11 23:14:44 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2026-08-17 16:41:59 +0200 |
| commit | a48f97c25d421c0da21467f8e0e736c19c58c6e1 (patch) | |
| tree | 053da4e524305ac3d3673ee7e088bfde4385464e /microprom/labels_test.go | |
| parent | ab5012e0083ff6623ffab78f52f9ea1120d80ffb (diff) | |
| download | go-gg-a48f97c25d421c0da21467f8e0e736c19c58c6e1.tar.gz | |
add package microprom
This does not have test coverage yet, because the test coverage will be
in the `testing/` module, but `go mod tidy` will not run there until
there is a commit that has the microprom package itself.
Diffstat (limited to 'microprom/labels_test.go')
| -rw-r--r-- | microprom/labels_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/microprom/labels_test.go b/microprom/labels_test.go new file mode 100644 index 0000000..0414be8 --- /dev/null +++ b/microprom/labels_test.go @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2026 Stefan Majewsky <majewsky@gmx.net> +// SPDX-License-Identifier: Apache-2.0 + +package microprom_test + +import ( + "testing" + + "go.xyrillian.de/gg/assert" + "go.xyrillian.de/gg/microprom" +) + +func TestFormatLabels(t *testing.T) { + ms := microprom.NewMetricSet(microprom.SyntaxOpenMetricsV1, nil) + + // the basic example from the documentation + names := microprom.NewLabelNames("foo", "hello") + labels := ms.FormatLabels(names, "bar", "world") + assert.Equal(t, labels, `foo="bar",hello="world"`) + + // test escaping label values + labels = ms.FormatLabels(names, "bar\\\n\\bar", `"universe\world"`) + assert.Equal(t, labels, `foo="bar\\\n\\bar",hello="\"universe\\world\""`) +} |
