From daf102f0c9234011e013d174b82861ef94decfe8 Mon Sep 17 00:00:00 2001 From: MrLotU Date: Mon, 2 Aug 2021 14:01:43 +0200 Subject: [PATCH] Fix label equality issue --- Sources/Prometheus/PrometheusMetrics.swift | 2 +- Sources/PrometheusExample/main.swift | 198 +++++++++--------- .../PrometheusMetricsTests.swift | 10 + 3 files changed, 110 insertions(+), 100 deletions(-) diff --git a/Sources/Prometheus/PrometheusMetrics.swift b/Sources/Prometheus/PrometheusMetrics.swift index 2fed018..0bfb930 100644 --- a/Sources/Prometheus/PrometheusMetrics.swift +++ b/Sources/Prometheus/PrometheusMetrics.swift @@ -354,7 +354,7 @@ public struct DimensionLabels: MetricLabels { for index in 0..? = prom.getMetricInstance(with: "duration_nanos", andType: .summary) XCTAssertNil(summary) } + + func testDimensionLabelEquality() { + let labelsA = DimensionLabels([("a", "a")]) + let labelsB = DimensionLabels([("b", "b")]) + let labelsATwo = DimensionLabels([("a", "a")]) + + XCTAssertEqual(labelsA, labelsATwo) + XCTAssertNotEqual(labelsA, labelsB) + XCTAssertNotEqual(labelsATwo, labelsB) + } }