diff --git a/pkg/metrics/parser_test.go b/pkg/metrics/parser_test.go index 8d6a680..f712eb2 100644 --- a/pkg/metrics/parser_test.go +++ b/pkg/metrics/parser_test.go @@ -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{