master
go 39 lines 1.16 KB
Raw
1 // SPDX-License-Identifier: GPL-3.0-or-later
2
3 package snmp
4
5 import (
6 "testing"
7
8 "github.com/stretchr/testify/assert"
9 )
10
11 func TestMetricIDs(t *testing.T) {
12 tests := map[string]struct {
13 call func() string
14 want string
15 }{
16 "generic profile metric name keeps legacy raw ID": {
17 call: func() string { return metricIDFromName("metric.with space", "sub.key with space") },
18 want: "snmp_device_prof_metric.with space_sub.key with space",
19 },
20 "generic profile metric key keeps legacy raw ID": {
21 call: func() string { return metricIDFromKey("metric_192.0.2.10 with space", "rx.bytes") },
22 want: "snmp_device_prof_metric_192.0.2.10 with space_rx.bytes",
23 },
24 "generic profile chart key stays cleaned": {
25 call: func() string { return chartIDFromKey("metric_192.0.2.10 with space") },
26 want: "snmp_device_prof_metric_192_0_2_10_with_space",
27 },
28 "BGP chart metric name uses cleaned ID": {
29 call: func() string { return metricIDFromName("bgp.peers.message_traffic", "received.total") },
30 want: "snmp_bgp_peers_message_traffic_received_total",
31 },
32 }
33
34 for name, tc := range tests {
35 t.Run(name, func(t *testing.T) {
36 assert.Equal(t, tc.want, tc.call())
37 })
38 }
39 }