mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 18:21:10 +00:00
Merge branch 'master' into other/gitignore-agents-md
This commit is contained in:
2 files changed
+10
-3
No files matched your search
@@ -93,7 +93,7 @@ public class Program
|
|||||||
SqliteConnection sqliteConnection = new(context.Database.GetDbConnection().ConnectionString);
|
SqliteConnection sqliteConnection = new(context.Database.GetDbConnection().ConnectionString);
|
||||||
sqliteConnection.Open();
|
sqliteConnection.Open();
|
||||||
using SqliteCommand sqliteCommand = sqliteConnection.CreateCommand();
|
using SqliteCommand sqliteCommand = sqliteConnection.CreateCommand();
|
||||||
sqliteCommand.CommandText = "PRAGMA journal_mode=WAL; PRAGMA busy_timeout=10000;";
|
sqliteCommand.CommandText = "PRAGMA journal_mode=WAL; PRAGMA busy_timeout=30000;";
|
||||||
sqliteCommand.ExecuteNonQuery();
|
sqliteCommand.ExecuteNonQuery();
|
||||||
sqliteConnection.Close();
|
sqliteConnection.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-2
@@ -26,7 +26,9 @@ namespace Lumina.Presentation.Api.IntegrationTests.Common.Setup;
|
|||||||
public class LuminaApiFactory : WebApplicationFactory<Program>, IDisposable
|
public class LuminaApiFactory : WebApplicationFactory<Program>, IDisposable
|
||||||
{
|
{
|
||||||
private readonly SqliteConnection _connection;
|
private readonly SqliteConnection _connection;
|
||||||
|
private readonly string _sharedInMemoryConnectionString;
|
||||||
private const string TEST_ENCRYPTION_KEY = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=";
|
private const string TEST_ENCRYPTION_KEY = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI=";
|
||||||
|
private const string SHARED_IN_MEMORY_CONNECTION_STRING_PREFIX = "Data Source=lumina-tests-{0};Mode=Memory;Cache=Shared";
|
||||||
private static byte s_IpClass = 25;
|
private static byte s_IpClass = 25;
|
||||||
|
|
||||||
public static byte IpClass => s_IpClass++;
|
public static byte IpClass => s_IpClass++;
|
||||||
@@ -36,7 +38,12 @@ public class LuminaApiFactory : WebApplicationFactory<Program>, IDisposable
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public LuminaApiFactory()
|
public LuminaApiFactory()
|
||||||
{
|
{
|
||||||
_connection = new SqliteConnection("DataSource=:memory:");
|
// each factory gets its own uniquely named shared in-memory database, so that parallel test classes remain isolated from one another;
|
||||||
|
// the shared cache allows each DbContext to open its own pooled connection to the same database, instead of sharing a single connection,
|
||||||
|
// which would otherwise serialize every request on one connection and cause nested transaction errors between requests
|
||||||
|
_sharedInMemoryConnectionString = string.Format(SHARED_IN_MEMORY_CONNECTION_STRING_PREFIX, Guid.NewGuid());
|
||||||
|
// keep a single anchor connection open, so that the shared in-memory database it refers to is not dropped
|
||||||
|
_connection = new SqliteConnection(_sharedInMemoryConnectionString);
|
||||||
_connection.Open();
|
_connection.Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +80,7 @@ public class LuminaApiFactory : WebApplicationFactory<Program>, IDisposable
|
|||||||
// add SQLite DbContext configuration
|
// add SQLite DbContext configuration
|
||||||
services.AddDbContext<LuminaDbContext>((serviceProvider, options) =>
|
services.AddDbContext<LuminaDbContext>((serviceProvider, options) =>
|
||||||
{
|
{
|
||||||
options.UseSqlite(_connection);
|
options.UseSqlite(_sharedInMemoryConnectionString);
|
||||||
options.AddInterceptors(serviceProvider.GetRequiredService<UpdateAuditableEntitiesInterceptor>());
|
options.AddInterceptors(serviceProvider.GetRequiredService<UpdateAuditableEntitiesInterceptor>());
|
||||||
});
|
});
|
||||||
// configure JWT authentication for testing
|
// configure JWT authentication for testing
|
||||||
|
|||||||
Reference in new issue
Block a user