Skip to content

Commit

Permalink
Added reproduction for akkadotnet#512
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Nov 6, 2024
1 parent 1a5ad32 commit 12a7917
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/Akka.Cluster.Hosting.Tests/DDataOptionsSpecs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Cluster.Sharding;
using Akka.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
using Xunit.Abstractions;

namespace Akka.Cluster.Hosting.Tests;

public class DDataOptionsSpecs
{
public DDataOptionsSpecs(ITestOutputHelper output)
{
Output = output;
}

public ITestOutputHelper Output { get; }

public static readonly TheoryData<DDataOptions> DDataOptionsTypes = new TheoryData<DDataOptions>()
{
new DDataOptions() // empty
{
Durable = new DurableOptions()
{
Keys = []
}
},
new DDataOptions() // null
{
Durable = new DurableOptions()
{
Keys = null
}
},
};

/// <summary>
/// Reproduction for https://github.com/akkadotnet/Akka.Hosting/issues/512
/// </summary>
[Theory]
[MemberData(nameof(DDataOptionsTypes))]
public async Task Should_not_emit_durable_keys_when_empty(DDataOptions options)
{
// arrange
using var host = await TestHelper.CreateHost(builder => { builder.WithDistributedData(options); },
new ClusterOptions() { Roles = new[] { "my-host" } }, Output);

var actorSystem = host.Services.GetRequiredService<ActorSystem>();

// act
var config = actorSystem.Settings.Config.GetConfig("akka.cluster.distributed-data");

// assert
Assert.True(config.HasPath("durable.keys"));
var keys = config.GetStringList("durable.keys");
Assert.Empty(keys);
}
}

0 comments on commit 12a7917

Please sign in to comment.