(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestMetricCounter(t *testing.T) { |
| 21 | const metric = "metric" |
| 22 | |
| 23 | for name, tc := range map[string]struct { |
| 24 | ignored []string |
| 25 | localLimit int |
| 26 | series int |
| 27 | expectedErrorOnLastSeries error |
| 28 | }{ |
| 29 | "no ignored metrics, limit not reached": { |
| 30 | ignored: nil, |
| 31 | localLimit: 5, |
| 32 | series: 5, |
| 33 | expectedErrorOnLastSeries: nil, |
| 34 | }, |
| 35 | |
| 36 | "no ignored metrics, limit reached": { |
| 37 | ignored: nil, |
| 38 | localLimit: 5, |
| 39 | series: 6, |
| 40 | expectedErrorOnLastSeries: errMaxSeriesPerMetricLimitExceeded, |
| 41 | }, |
| 42 | |
| 43 | "ignored metric, limit not reached": { |
| 44 | ignored: []string{metric}, |
| 45 | localLimit: 5, |
| 46 | series: 5, |
| 47 | expectedErrorOnLastSeries: nil, |
| 48 | }, |
| 49 | |
| 50 | "ignored metric, over limit": { |
| 51 | ignored: []string{metric}, |
| 52 | localLimit: 5, |
| 53 | series: 10, |
| 54 | expectedErrorOnLastSeries: nil, // this metric is not checked for series-count. |
| 55 | }, |
| 56 | |
| 57 | "ignored different metric, limit not reached": { |
| 58 | ignored: []string{"another_metric1", "another_metric2"}, |
| 59 | localLimit: 5, |
| 60 | series: 5, |
| 61 | expectedErrorOnLastSeries: nil, |
| 62 | }, |
| 63 | |
| 64 | "ignored different metric, over limit": { |
| 65 | ignored: []string{"another_metric1", "another_metric2"}, |
| 66 | localLimit: 5, |
| 67 | series: 6, |
| 68 | expectedErrorOnLastSeries: errMaxSeriesPerMetricLimitExceeded, |
| 69 | }, |
| 70 | } { |
| 71 | t.Run(name, func(t *testing.T) { |
| 72 | var ignored map[string]struct{} |
| 73 | if tc.ignored != nil { |
| 74 | ignored = make(map[string]struct{}) |
| 75 | for _, v := range tc.ignored { |
| 76 | ignored[v] = struct{}{} |
| 77 | } |
nothing calls this directly
no test coverage detected