(t *testing.T)
| 31 | } |
| 32 | |
| 33 | func TestAddSubmetric(t *testing.T) { |
| 34 | t.Parallel() |
| 35 | testdata := map[string]struct { |
| 36 | err bool |
| 37 | tags map[string]string |
| 38 | }{ |
| 39 | "": {true, nil}, |
| 40 | " ": {true, nil}, |
| 41 | "a": {false, map[string]string{"a": ""}}, |
| 42 | "a:1": {false, map[string]string{"a": "1"}}, |
| 43 | " a : 1 ": {false, map[string]string{"a": "1"}}, |
| 44 | "a,b": {false, map[string]string{"a": "", "b": ""}}, |
| 45 | ` a:"",b: ''`: {false, map[string]string{"a": "", "b": ""}}, |
| 46 | `a:1,b:2`: {false, map[string]string{"a": "1", "b": "2"}}, |
| 47 | ` a : 1, b : 2 `: {false, map[string]string{"a": "1", "b": "2"}}, |
| 48 | `a : '1' , b : "2"`: {false, map[string]string{"a": "1", "b": "2"}}, |
| 49 | `" a" : ' 1' , b : "2 " `: {false, map[string]string{" a": " 1", "b": "2 "}}, //nolint:gocritic |
| 50 | } |
| 51 | |
| 52 | for name, expected := range testdata { |
| 53 | t.Run(name, func(t *testing.T) { |
| 54 | t.Parallel() |
| 55 | |
| 56 | r := NewRegistry() |
| 57 | m := r.MustNewMetric("metric", Trend) |
| 58 | sm, err := m.AddSubmetric(name) |
| 59 | if expected.err { |
| 60 | require.Error(t, err) |
| 61 | return |
| 62 | } |
| 63 | require.NoError(t, err) |
| 64 | require.NotNil(t, sm) |
| 65 | assert.EqualValues(t, expected.tags, sm.Tags.Map()) |
| 66 | }) |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | func TestParseMetricName(t *testing.T) { |
| 71 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…