mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-19 07:01:02 +01:00
d6b4c8e4ef
Co-authored-by: Andrew Chubatiuk <andrew.chubatiuk@motional.com>
Co-authored-by: Nikolay <https://github.com/f41gh7>
Co-authored-by: Roman Khavronenko <roman@victoriametrics.com>
(cherry picked from commit 543f218fe9
)
Signed-off-by: hagen1778 <roman@victoriametrics.com>
24 lines
916 B
Go
24 lines
916 B
Go
package stream
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSanitizeName(t *testing.T) {
|
|
f := func(s, resultExpected string) {
|
|
t.Helper()
|
|
result := sanitizeName(true)(s)
|
|
if result != resultExpected {
|
|
t.Fatalf("unexpected result for sanitizeName(%q); got\n%q\nwant\n%q", s, result, resultExpected)
|
|
}
|
|
}
|
|
f("before.dot.metric!.name", "before.dot.metric.name")
|
|
f("after.dot.metric.!name", "after.dot.metric.name")
|
|
f("in.the.middle.met!ric.name", "in.the.middle.met_ric.name")
|
|
f("before.and.after.and.middle.met!ric!.!name", "before.and.after.and.middle.met_ric.name")
|
|
f("many.consecutive.met!!!!ric!!.!!name", "many.consecutive.met_ric.name")
|
|
f("many.non.consecutive.m!e!t!r!i!c!.!name", "many.non.consecutive.m_e_t_r_i_c.name")
|
|
f("how.about.underscores_.!_metric!_!.__!!name", "how.about.underscores.metric.name")
|
|
f("how.about.underscores.middle.met!_!_ric.name", "how.about.underscores.middle.met_ric.name")
|
|
}
|