Mute logspam

This commit is contained in:
2026-04-04 20:33:44 +02:00
parent 22ee512cb7
commit 2e6951e695
4 changed files with 33 additions and 16 deletions

View File

@@ -1,6 +1,8 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Logging;
using RpgRoller.Data;
using RpgRoller.Hosting;
@@ -31,20 +33,29 @@ public abstract class ApiTestBase : IClassFixture<WebApplicationFactory<Program>
protected WebApplicationFactory<Program> CreateFactory(params int[] rollValues)
{
return m_BaseFactory.WithWebHostBuilder(builder => builder.ConfigureServices(services =>
return m_BaseFactory.WithWebHostBuilder(builder =>
{
services.RemoveAll<IDiceRoller>();
services.AddSingleton<IDiceRoller>(new FixedDiceRoller(rollValues));
builder.ConfigureLogging(logging =>
{
logging.AddFilter("Microsoft.AspNetCore", LogLevel.Warning);
logging.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning);
logging.AddFilter("Microsoft.Hosting", LogLevel.Warning);
});
builder.ConfigureServices(services =>
{
services.RemoveAll<IDiceRoller>();
services.AddSingleton<IDiceRoller>(new FixedDiceRoller(rollValues));
services.RemoveAll<DbContextOptions<RpgRollerDbContext>>();
services.RemoveAll<IDbContextFactory<RpgRollerDbContext>>();
services.RemoveAll<RpgRollerDbContext>();
services.RemoveAll<SqliteDatabaseFile>();
services.RemoveAll<DbContextOptions<RpgRollerDbContext>>();
services.RemoveAll<IDbContextFactory<RpgRollerDbContext>>();
services.RemoveAll<RpgRollerDbContext>();
services.RemoveAll<SqliteDatabaseFile>();
var dbPath = Path.Combine(Path.GetTempPath(), $"rpgroller-tests-{Guid.NewGuid():N}.db");
services.AddSingleton(new SqliteDatabaseFile(dbPath));
services.AddDbContextFactory<RpgRollerDbContext>(options => options.UseSqlite($"Data Source={dbPath}"));
}));
var dbPath = Path.Combine(Path.GetTempPath(), $"rpgroller-tests-{Guid.NewGuid():N}.db");
services.AddSingleton(new SqliteDatabaseFile(dbPath));
services.AddDbContextFactory<RpgRollerDbContext>(options => options.UseSqlite($"Data Source={dbPath}"));
});
});
}
protected static async Task<UserSummary> RegisterAsync(HttpClient client, string username, string password, string displayName)