MCPcopy
hub / github.com/prometheus/client_golang / TestCurryVecWithConstraints

Function TestCurryVecWithConstraints

prometheus/vec_test.go:473–504  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

471}
472
473func TestCurryVecWithConstraints(t *testing.T) {
474 constraint := func(s string) string { return "x" + s }
475 t.Run("constrainedLabels overlap variableLabels", func(t *testing.T) {
476 vec := V2.NewCounterVec(CounterVecOpts{
477 CounterOpts{
478 Name: "test",
479 Help: "helpless",
480 },
481 ConstrainedLabels{
482 {Name: "one"},
483 {Name: "two"},
484 {Name: "three", Constraint: constraint},
485 },
486 })
487 testCurryVec(t, vec)
488 })
489 t.Run("constrainedLabels reducing cardinality", func(t *testing.T) {
490 constraint := func(s string) string { return "x" }
491 vec := V2.NewCounterVec(CounterVecOpts{
492 CounterOpts{
493 Name: "test",
494 Help: "helpless",
495 },
496 ConstrainedLabels{
497 {Name: "one"},
498 {Name: "two"},
499 {Name: "three", Constraint: constraint},
500 },
501 })
502 testConstrainedCurryVec(t, vec, constraint)
503 })
504}
505
506func testCurryVec(t *testing.T, vec *CounterVec) {
507 assertMetrics := func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

testCurryVecFunction · 0.85
testConstrainedCurryVecFunction · 0.85
RunMethod · 0.80
NewCounterVecMethod · 0.45

Tested by

no test coverage detected