master
go 33 lines 955 Bytes
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package collecttest
4
5 import (
6 "testing"
7
8 "github.com/netdata/netdata/go/plugins/plugin/framework/collectorapi"
9 "github.com/stretchr/testify/assert"
10 )
11
12 func TestMetricsHasAllChartsDims(t *testing.T, charts *collectorapi.Charts, mx map[string]int64) {
13 TestMetricsHasAllChartsDimsSkip(t, charts, mx, nil)
14 }
15
16 func TestMetricsHasAllChartsDimsSkip(t *testing.T, charts *collectorapi.Charts, mx map[string]int64, skip func(chart *collectorapi.Chart, dim *collectorapi.Dim) bool) {
17 for _, chart := range *charts {
18 if chart.Obsolete {
19 continue
20 }
21 for _, dim := range chart.Dims {
22 if skip != nil && skip(chart, dim) {
23 continue
24 }
25 _, ok := mx[dim.ID]
26 assert.Truef(t, ok, "missing data for dimension '%s' in chart '%s'", dim.ID, chart.ID)
27 }
28 for _, v := range chart.Vars {
29 _, ok := mx[v.ID]
30 assert.Truef(t, ok, "missing data for variable '%s' in chart '%s'", v.ID, chart.ID)
31 }
32 }
33 }