Skip to content

Commit

Permalink
fix: fix issue in seed-manager
Browse files Browse the repository at this point in the history
  • Loading branch information
meysamhadeli committed Dec 19, 2024
1 parent cc8989a commit b9aa18a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/BuildingBlocks/EFCore/SeedManagers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace BuildingBlocks.EFCore;
Expand All @@ -15,11 +16,14 @@ public async Task ExecuteSeedAsync()
await using var scope = serviceProvider.CreateAsyncScope();
var dataSeeders = scope.ServiceProvider.GetServices<IDataSeeder>();

foreach (var seeder in dataSeeders.Where(x => x is not ITestDataSeeder))
if (!env.IsEnvironment("test"))
{
logger.LogInformation("Seed {SeederName} is started.", seeder.GetType().Name);
await seeder.SeedAllAsync();
logger.LogInformation("Seed {SeederName} is completed.", seeder.GetType().Name);
foreach (var seeder in dataSeeders.Where(x => x is not ITestDataSeeder))
{
logger.LogInformation("Seed {SeederName} is started.", seeder.GetType().Name);
await seeder.SeedAllAsync();
logger.LogInformation("Seed {SeederName} is completed.", seeder.GetType().Name);
}
}
}

Expand All @@ -28,7 +32,7 @@ public async Task ExecuteTestSeedAsync()
await using var scope = serviceProvider.CreateAsyncScope();
var dataSeeders = scope.ServiceProvider.GetServices<IDataSeeder>();

foreach (var seeder in dataSeeders.Where(x => x is not ITestDataSeeder))
foreach (var seeder in dataSeeders.Where(x => x is ITestDataSeeder))
{
logger.LogInformation("Seed {SeederName} is started.", seeder.GetType().Name);
await seeder.SeedAllAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace Integration.Test;

public class IdentityDataSeeder(
public class IdentityTestDataSeeder(
UserManager<User> userManager,
RoleManager<Role> roleManager,
IEventDispatcher eventDispatcher
)
: IDataSeeder
: ITestDataSeeder
{
public async Task SeedAllAsync()
{
Expand Down

0 comments on commit b9aa18a

Please sign in to comment.