Path: redb-identity/tests/redb.Identity.Tests/Infrastructure/PostgresFixture.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Tests/Infrastructure/PostgresFixture.cs ---- using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Xunit; using redb.Core; using redb.Core.Models.Configuration; using redb.Core.Extensions; using redb.Core.Pro.Extensions; using redb.Postgres.Pro.Extensions; using redb.Identity.Core.Models; using redb.Identity.DataProtection; namespace redb.Identity.Tests.Infrastructure; public class PostgresFixture : IAsyncLifetime { public IRedbService Redb { get; private set; } = null!; public ServiceProvider Services { get; private set; } = null!; public async Task InitializeAsync() { var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); var cs = config.GetPostgresConnectionString() ?? throw new InvalidOperationException("ConnectionStrings:Postgres not found in appsettings.json"); var sc = new ServiceCollection(); sc.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Warning)); sc.AddRedbForTests(cs); Services = sc.BuildServiceProvider(); Redb = Services.GetRequiredService(); try { await Redb.InitializeAsync(ensureCreated: true); } catch (Exception ex) { Console.Error.WriteLine($"InitializeAsync(ensureCreated:true) failed, falling back: {ex.GetType().Name}: {ex.Message}"); await Redb.InitializeAsync(); } await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.SyncSchemeAsync(); await Redb.InitializeTypeRegistryAsync(); // Fix btree index overflow for large Payload values (4+ scope tokens) await IndexFixHelper.FixValueStringIndexAsync(cs); } public async Task DisposeAsync() { if (Services is not null) await Services.DisposeAsync(); } }