From ae387c23aeb3332753677212bb74c4407e5fa81f Mon Sep 17 00:00:00 2001 From: alessandro negrin Date: Tue, 29 Nov 2022 15:32:17 +0100 Subject: [PATCH] tests --- pkg/metrics/parser_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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{