swift-server / swift-prometheus

Prometheus client library for Swift
https://swiftpackageindex.com/swift-server/swift-prometheus
Apache License 2.0
145 stars 32 forks source link

Fixup tests since we're now all async #2

Closed Yasumoto closed 5 years ago

Yasumoto commented 5 years ago

The API is now always running against an async DispatchQueue; so we want the tests to verify that process works as expected. I added a callback to both the Summary and Histogram so we could toggle a DispatchSemaphore, which seemed like the easiest path for syncronization.

Checklist

Motivation and Context

The tests should now be working as expected.

Test Run

jmsmith@SFO-M-JMSMITH01 ~/w/g/M/SwiftPrometheus (master)> swift test                           10:26:37
[5/5] Linking ./.build/x86_64-apple-macosx/debug/SwiftPrometheusPackageTests.xctest/Contents/MacOS/S…
Test Suite 'All tests' started at 2019-04-15 10:27:25.485
Test Suite 'SwiftPrometheusPackageTests.xctest' started at 2019-04-15 10:27:25.485
Test Suite 'SwiftPrometheusTests' started at 2019-04-15 10:27:25.485
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testCounter]' started.
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testCounter]' passed (0.174 seconds).
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testGauge]' started.
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testGauge]' passed (0.000 seconds).
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testHistogram]' started.
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testHistogram]' passed (0.001 seconds).
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testInfo]' started.
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testInfo]' passed (0.000 seconds).
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testSummary]' started.
Test Case '-[SwiftPrometheusTests.SwiftPrometheusTests testSummary]' passed (0.001 seconds).
Test Suite 'SwiftPrometheusTests' passed at 2019-04-15 10:27:25.662.
     Executed 5 tests, with 0 failures (0 unexpected) in 0.177 (0.177) seconds
Test Suite 'SwiftPrometheusPackageTests.xctest' passed at 2019-04-15 10:27:25.662.
     Executed 5 tests, with 0 failures (0 unexpected) in 0.177 (0.177) seconds
Test Suite 'All tests' passed at 2019-04-15 10:27:25.663.
     Executed 5 tests, with 0 failures (0 unexpected) in 0.177 (0.177) seconds