From 7719e01dec4e3c9262797244ca63234cc9b2d2ea Mon Sep 17 00:00:00 2001 From: Serge K Date: Fri, 13 Dec 2024 22:15:30 +0700 Subject: [PATCH] add push server test --- tests/MetricPushServerTests.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/MetricPushServerTests.cs b/tests/MetricPushServerTests.cs index 030920d..57b795d 100644 --- a/tests/MetricPushServerTests.cs +++ b/tests/MetricPushServerTests.cs @@ -8,7 +8,7 @@ namespace Prometheus.Client.MetricPusher.Tests; public class MetricPushServerTests { [Fact] - public async Task PushContinuesOnError() + public async Task Push_WithDefaultInterval_ContinuesOnError_InvokedExpectedTimes() { var pusher = Substitute.For(); pusher.PushAsync().Returns(Task.FromException(new Exception("Simulated Push Error"))); @@ -20,4 +20,18 @@ public async Task PushContinuesOnError() await pusher.Received(3).PushAsync(); worker.Stop(); } + + [Fact] + public async Task Push_WithCustomInterval_ContinuesOnError_InvokedExpectedTimes() + { + var pusher = Substitute.For(); + pusher.PushAsync().Returns(Task.FromException(new Exception("Simulated Push Error"))); + + var worker = new MetricPushServer(pusher, TimeSpan.FromMilliseconds(500)); + worker.Start(); + await Task.Delay(2250); + + await pusher.Received(5).PushAsync(); + worker.Stop(); + } }