Skip to content

Commit

Permalink
Added reproduction for #512
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Nov 6, 2024
1 parent fed3d52 commit 18bdbbb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
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);
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>10.0</LangVersion>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down

0 comments on commit 18bdbbb

Please sign in to comment.