fix: try to fix failed tests in ci

This commit is contained in:
Meysam Hadeli 2024-12-19 01:33:06 +03:30
parent e871a37217
commit bd345ae949
3 changed files with 7 additions and 8 deletions

View File

@ -51,7 +51,10 @@ public static class Extensions
services.AddScoped<IPersistMessageProcessor, PersistMessageProcessor>();
services.AddHostedService<PersistMessageBackgroundService>();
if (env.EnvironmentName != "test")
{
services.AddHostedService<PersistMessageBackgroundService>();
}
return services;
}

View File

@ -14,15 +14,12 @@ public class PersistMessageBackgroundService(
{
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)

View File

@ -95,8 +95,7 @@ where TEntryPoint : class
{
TestRegistrationServices?.Invoke(services);
services.ReplaceSingleton(AddHttpContextAccessorMock);
services.RemoveAll<IHostedService>();
// services.RemoveAll<IHostedService>();
services.AddSingleton<PersistMessageBackgroundService>();
// Register all ITestDataSeeder implementations dynamically