This commit is contained in:
alessandro negrin
2022-11-30 10:02:48 +01:00
parent a76297e47c
commit ae387c23ae
+26
View File
@@ -26,6 +26,32 @@ func TestParser_parseMetric(t *testing.T) {
want Metric
wantErr bool
}{
{
name: "value without timestamp",
fields: fields{
map[string][]config.MetricConfig{
"temperature": []config.MetricConfig{
{
PrometheusName: "temperature",
ValueType: "gauge",
OmitTimestamp: true,
},
},
},
},
args: args{
metricPath: "temperature",
deviceID: "dht22",
value: 12.6,
},
want: Metric{
Description: prometheus.NewDesc("temperature", "", []string{"sensor", "topic"}, nil),
ValueType: prometheus.GaugeValue,
Value: 12.6,
IngestTime: time.Time{},
Topic: "",
},
},
{
name: "string value",
fields: fields{