Skip to content

Commit

Permalink
Finally made the dead letter queue http tests be more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Aug 20, 2024
1 parent 30f3756 commit dfe249a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public async Task can_call_through()
});

builder.Services.AddControllers();

builder.Services.AddWolverineHttp();

// This is using Alba, which uses WebApplicationFactory under the covers
await using var host = await AlbaHost.For(builder, app =>
Expand Down
36 changes: 25 additions & 11 deletions src/Http/Wolverine.Http.Tests/dead_letter_endpoints.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using JasperFx.Core.Reflection;
using Shouldly;
using Wolverine.Tracking;
using WolverineWebApi;

namespace Wolverine.Http.Tests;
Expand All @@ -11,10 +12,14 @@ public async Task fetch_them()
{
// Given
var exceptionMessage = $"fetchable-{Guid.NewGuid()}";
await Scenario(x =>

await Host.TrackActivity().DoNotAssertOnExceptionsDetected().ExecuteAndWaitAsync(_ =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
return Scenario(x =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
});
});

// When
Expand Down Expand Up @@ -46,12 +51,16 @@ public async Task replay_one()
{
// Given
var exceptionMessage = $"replayable-{Guid.NewGuid()}";
await Scenario(x =>

await Host.TrackActivity().DoNotAssertOnExceptionsDetected().ExecuteAndWaitAsync(_ =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
return Scenario(x =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
});
});

var result = await Scenario(x =>
{
x.Post.Json(new DeadLetterEnvelopeGetRequest
Expand All @@ -76,12 +85,16 @@ public async Task delete_one()
{
// Given
var exceptionMessage = $"deletable-{Guid.NewGuid()}";
await Scenario(x =>

await Host.TrackActivity().DoNotAssertOnExceptionsDetected().ExecuteAndWaitAsync(_ =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
return Scenario(x =>
{
x.Post.Json(new MessageThatAlwaysGoesToDeadLetter(exceptionMessage)).ToUrl("/send/always-dead-letter");
x.StatusCodeShouldBe(202);
});
});

var result = await Scenario(x =>
{
x.Post.Json(new DeadLetterEnvelopeGetRequest
Expand All @@ -92,6 +105,7 @@ await Scenario(x =>

// When & Expect
var deadletters = result.ReadAsJson<DeadLetterEnvelopesFoundResponse>();

await Scenario(x =>
{
x.Delete.Json(new DeadLetterEnvelopeIdsRequest
Expand Down

0 comments on commit dfe249a

Please sign in to comment.