Skip to content

Commit

Permalink
Merge custom config with default config (#4404)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdan-Rotund authored May 7, 2020
1 parent d3e4f92 commit 9ae970e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/core/Akka.Persistence.TestKit.Xunit2/PersistenceTestKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class PersistenceTestKit : TestKit
/// <param name="actorSystemName">Optional: The name of the actor system</param>
/// <param name="output">TBD</param>
protected PersistenceTestKit(Config config, string actorSystemName = null, ITestOutputHelper output = null)
: base(config, actorSystemName, output)
: base(GetConfig(config), actorSystemName, output)
{
var persistenceExtension = Persistence.Instance.Apply(Sys);

Expand All @@ -48,7 +48,7 @@ protected PersistenceTestKit(Config config, string actorSystemName = null, ITest
/// <param name="actorSystemName">Optional: The name of the actor system</param>
/// <param name="output">TBD</param>
protected PersistenceTestKit(string actorSystemName = null, ITestOutputHelper output = null)
: this(GetConfig(), actorSystemName, output)
: this(Config.Empty, actorSystemName, output)
{
}

Expand Down Expand Up @@ -286,14 +286,19 @@ public Task WithSnapshotDelete(Func<SnapshotStoreDeleteBehavior, Task> behaviorS
execution();
return Task.FromResult(true);
});

/// <summary>
/// Loads from embedded resources actor system persistence configuration with <see cref="TestJournal"/> and
/// <see cref="TestSnapshotStore"/> configured as default persistence plugins.
/// </summary>
/// <param name="customConfig">Custom configuration that was passed in the constructor.</param>
/// <returns>Actor system configuration object.</returns>
/// <seealso cref="Config"/>
static Config GetConfig()
=> ConfigurationFactory.FromResource<TestJournal>("Akka.Persistence.TestKit.config.conf");
private static Config GetConfig(Config customConfig)
{
var defaultConfig = ConfigurationFactory.FromResource<TestJournal>("Akka.Persistence.TestKit.config.conf");
if (customConfig == Config.Empty) return defaultConfig;
else return defaultConfig.SafeWithFallback(customConfig);
}
}
}

0 comments on commit 9ae970e

Please sign in to comment.