Skip to content

Commit

Permalink
Don't apply stateful resources for external transports if running stu…
Browse files Browse the repository at this point in the history
…bbed. Closes GH-630
  • Loading branch information
jeremydmiller committed Nov 13, 2023
1 parent 21ced43 commit e31a872
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/end_to_end.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,35 @@ public void rabbitmq_transport_is_exposed_as_a_resource()
publisher.Services.GetServices<IStatefulResourceSource>().SelectMany(x => x.FindResources())
.OfType<BrokerResource>().Any(x => x.Name == new RabbitMqTransport().Name).ShouldBeTrue();
}

[Fact]
public void rabbitmq_transport_is_NOT_exposed_as_a_resource_if_external_transports_are_stubbed()
{
var queueName = RabbitTesting.NextQueueName();
using var publisher = WolverineHost.For(opts =>
{
opts.UseRabbitMq().AutoProvision().AutoPurgeOnStartup();

opts.PublishAllMessages()
.ToRabbitQueue(queueName)
.UseDurableOutbox();

opts.StubAllExternalTransports();

opts.Services.AddMarten(x =>
{
x.Connection(Servers.PostgresConnectionString);
x.AutoCreateSchemaObjects = AutoCreate.All;
x.DatabaseSchemaName = "sender";
}).IntegrateWithWolverine();

opts.Services.AddResourceSetupOnStartup(StartupAction.ResetState);
});

publisher.Services.GetServices<IStatefulResourceSource>().SelectMany(x => x.FindResources())
.OfType<BrokerResource>().Any(x => x.Name == new RabbitMqTransport().Name).ShouldBeFalse();
}



[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public partial class WolverineRuntime : IStatefulResourceSource
IReadOnlyList<IStatefulResource> IStatefulResourceSource.FindResources()
{
var list = new List<IStatefulResource>();
if (Options.ExternalTransportsAreStubbed) return list;

foreach (var transport in Options.Transports)
{
Expand Down

0 comments on commit e31a872

Please sign in to comment.