mirror of
https://github.com/hikhvar/mqtt2prometheus.git
synced 2026-08-23 21:16:15 +00:00
tests
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user