Path: redb/redb.Tests.Integration/Tests/Base/StreamsIndexOnceTestsBase.cs Snapshot: redb, 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 Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Base/StreamsIndexOnceTestsBase.cs ---- using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using redb.Core; using redb.Core.Data; using redb.Core.Models; using redb.Core.Models.Configuration; namespace redb.Tests.Integration.Tests.Base; /// /// Pro with the planner on builds the indexes of the streams query form once, at the module step that brings them (here: /// the database it creates). A start after that does not build a dropped one again: the index check reports it as a Pro /// module index, and the repair builds it. /// public abstract class StreamsIndexOnceTestsBase { protected abstract Task CreateDatabaseAsync(string name); protected abstract Task DropDatabaseAsync(string name); protected abstract void AddRedbPro(IServiceCollection services, string connectionString, Action configure); protected abstract string StreamsIndex { get; } protected abstract string DropStreamsIndexSql { get; } [Fact] public async Task DroppedStreamsIndex_IsNotRebuiltAtStart_ButReportedAndRepaired() { var name = $"redb_idxonce_{Guid.NewGuid():N}"[..24]; var connectionString = await CreateDatabaseAsync(name); try { await using (var sp = Build(connectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(ensureCreated: true); (await redb.CheckBaseIndexesAsync()).Findings.Should().BeEmpty("a database Pro creates gets its streams indexes"); await sp.GetRequiredService().ExecuteAsync(DropStreamsIndexSql); } await using (var sp = Build(connectionString)) { var redb = sp.GetRequiredService(); await redb.InitializeAsync(); var finding = (await redb.CheckBaseIndexesAsync()).Findings.Should().ContainSingle().Subject; finding.Name.Should().Be(StreamsIndex, "a start that is not the module step builds nothing"); finding.State.Should().Be(RedbIndexState.Missing); finding.Expected.Origin.Should().Be(RedbIndexOrigin.ProModule); (await redb.RepairBaseIndexesAsync(allowOffline: true)).Built.Should().Equal([StreamsIndex]); (await redb.CheckBaseIndexesAsync()).Findings.Should().BeEmpty(); } } finally { await DropDatabaseAsync(name); } } private ServiceProvider Build(string connectionString) { var services = new ServiceCollection(); services.AddLogging(b => b.SetMinimumLevel(LogLevel.Warning)); AddRedbPro(services, connectionString, c => { c.EnablePropsCache = false; c.EnablePvtPrefilter = true; }); return services.BuildServiceProvider(); } }