Path: redb/redb.Tests.Integration/Tests/SqlitePro/SqliteProIndexCatalogTests.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/SqlitePro/SqliteProIndexCatalogTests.cs
----
using Microsoft.Data.Sqlite;
using Microsoft.Extensions.DependencyInjection;
using redb.Core.Data;
using redb.Core.Extensions;
using redb.Core.Models;
using redb.Core.Models.Configuration;
using redb.SQLite.Data;
using redb.SQLite.Extensions;
using redb.SQLite.Sql;
using redb.Tests.Integration.Fixtures;
using redb.Tests.Integration.Tests.Base;
namespace redb.Tests.Integration.Tests.SqlitePro;
/// SqliteProIndexCatalog.Pro (the Pro module indexes) against a fresh SQLite Pro file of this build (see ).
public class SqliteProIndexCatalogTests : IndexCatalogTestsBase
{
private readonly Dictionary _files = new();
protected override Task CreateDatabaseAsync(string name)
{
SqliteDataSource.NativeExtensionPath ??= SqliteTestSupport.ResolveNativeExtension();
var path = Path.Combine(Path.GetTempPath(), name + ".db");
_files[name] = path;
return Task.FromResult($"Data Source={path}");
}
protected override Task DropDatabaseAsync(string name)
{
SqliteConnection.ClearAllPools();
if (_files.TryGetValue(name, out var path))
foreach (var file in new[] { path, path + "-wal", path + "-shm" })
{
try { if (File.Exists(file)) File.Delete(file); }
catch (IOException) { }
}
return Task.CompletedTask;
}
protected override void AddRedb(IServiceCollection services, string connectionString, Action configure)
=> redb.Core.Pro.Extensions.RedbProServiceCollectionExtensions.AddRedbPro(services, o => redb.SQLite.Pro.Extensions.SqliteProOptionsExtensions.UseSqlite(o, connectionString).Configure(configure));
protected override async Task> ReadCreateStatementsAsync(IRedbContext context)
{
var rows = await context.QueryAsync("SELECT name AS \"Name\", sql AS \"Sql\" FROM sqlite_master WHERE type = 'index' AND sql IS NOT NULL");
return rows.ToDictionary(r => r.Name!, r => r.Sql!, StringComparer.OrdinalIgnoreCase);
}
protected override IReadOnlyList Catalog => redb.SQLite.Pro.Sql.SqliteProIndexCatalog.Pro;
protected override IReadOnlyList CoveredElsewhere => SqliteIndexCatalog.Base;
protected override (string File, string Namespace, string Class, string Member, RedbIndexOrigin Origin) Target =>
("redb.SQLite.Pro/Sql/SqliteProIndexCatalog.g.cs", "redb.SQLite.Pro.Sql", "SqliteProIndexCatalog", "Pro", RedbIndexOrigin.ProModule);
private sealed class SqlRow
{
public string? Name { get; set; }
public string? Sql { get; set; }
}
}