Skip to content

Commit

Permalink
fix: try to fix failed tests in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
meysamhadeli committed Dec 18, 2024
1 parent e871a37 commit bd345ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/BuildingBlocks/PersistMessageProcessor/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ IWebHostEnvironment env

services.AddScoped<IPersistMessageProcessor, PersistMessageProcessor>();

services.AddHostedService<PersistMessageBackgroundService>();
if (env.EnvironmentName != "test")
{
services.AddHostedService<PersistMessageBackgroundService>();
}

return services;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@ IOptions<PersistMessageOptions> options
{
private PersistMessageOptions _options = options.Value;

private Task? _executingTask;

protected override Task ExecuteAsync(CancellationToken stoppingToken)
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
logger.LogInformation("PersistMessage Background Service Start");

_executingTask = ProcessAsync(stoppingToken);
await ProcessAsync(stoppingToken);

return _executingTask;
}

public override Task StopAsync(CancellationToken cancellationToken)
Expand Down
3 changes: 1 addition & 2 deletions src/BuildingBlocks/TestBase/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ protected TestFixture()
{
TestRegistrationServices?.Invoke(services);
services.ReplaceSingleton(AddHttpContextAccessorMock);
services.RemoveAll<IHostedService>();

// services.RemoveAll<IHostedService>();
services.AddSingleton<PersistMessageBackgroundService>();

// Register all ITestDataSeeder implementations dynamically
Expand Down

0 comments on commit bd345ae

Please sign in to comment.