Skip to content

Commit

Permalink
fixed more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <[email protected]>
  • Loading branch information
bacherfl committed Jan 2, 2024
1 parent 0f5a4a8 commit 8f40909
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/OpenFeature/EventExecutor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Channels;
Expand Down Expand Up @@ -91,6 +93,10 @@ internal void RemoveClientHandler(string client, ProviderEventTypes type, EventH

internal void RegisterDefaultFeatureProvider(FeatureProvider provider)
{
if (provider == null)
{
return;
}
this._mutex.WaitOne();
var oldProvider = this._defaultProvider;

Expand Down Expand Up @@ -128,7 +134,15 @@ private void StartListeningAndShutdownOld(FeatureProviderReference newProvider,
if (oldProvider != null && !this.IsProviderBound(oldProvider))
{
this._activeSubscriptions.Remove(oldProvider);
oldProvider.Provider.GetEventChannel().Writer.TryWrite(new ShutdownSignal());
if (oldProvider.Provider == null)
{
Console.WriteLine("wtf");
}

Check warning on line 140 in src/OpenFeature/EventExecutor.cs

View check run for this annotation

Codecov / codecov/patch

src/OpenFeature/EventExecutor.cs#L138-L140

Added lines #L138 - L140 were not covered by tests
var channel = oldProvider.Provider.GetEventChannel();
if (channel != null)
{
channel.Writer.TryWrite(new ShutdownSignal());
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions test/OpenFeature.Tests/OpenFeatureEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public async Task Event_Executor_Should_Propagate_Events_ToGlobal_Handler()
var eventPayload = new Event { EventPayload = new ProviderEventPayload { Type = ProviderEventTypes.ProviderReady }};
eventExecutor.EventChannel.Writer.TryWrite(eventPayload);

Thread.Sleep(1000);

eventHandler.Received().Invoke(Arg.Is<ProviderEventPayload>(payload => payload.Type == ProviderEventTypes.ProviderReady));

// shut down the event executor
Expand Down

0 comments on commit 8f40909

Please sign in to comment.