Skip to content

Commit

Permalink
add push server test
Browse files Browse the repository at this point in the history
  • Loading branch information
phnx47 committed Dec 13, 2024
1 parent 822a86e commit 7719e01
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/MetricPushServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMetricPusher>();
pusher.PushAsync().Returns(Task.FromException(new Exception("Simulated Push Error")));
Expand All @@ -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<IMetricPusher>();
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();
}
}

0 comments on commit 7719e01

Please sign in to comment.