Fix NewSchemaPerFixture
I don't know if this is a hacky fix, someone might have to take a look at it
This commit is contained in:
@@ -20,7 +20,6 @@ using Umbraco.Tests.Testing;
|
||||
namespace Umbraco.Tests.Packaging
|
||||
{
|
||||
[TestFixture]
|
||||
[Explicit] // TODO: find out why tests only run one at at time, the tests get blocked after the first test
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
|
||||
public class CreatedPackagesRepositoryTests : UmbracoIntegrationTest
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@ using Umbraco.Tests.Testing;
|
||||
namespace Umbraco.Tests.Services
|
||||
{
|
||||
[TestFixture]
|
||||
[Explicit]
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
|
||||
public class ConsentServiceTests : UmbracoIntegrationTest
|
||||
{
|
||||
|
||||
@@ -25,6 +25,14 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
public const string InstanceName = "UmbracoTests";
|
||||
public const string DatabaseName = "UmbracoTests";
|
||||
|
||||
public bool HasSchema
|
||||
{
|
||||
get
|
||||
{
|
||||
return !(_schemaPool is null) && !_schemaPool.CanAttach;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly LocalDb _localDb;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
@@ -254,6 +262,7 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
|
||||
private class DatabasePool
|
||||
{
|
||||
public bool CanAttach => _readyQueue.Count > 0;
|
||||
private readonly LocalDb _localDb;
|
||||
private readonly LocalDb.Instance _instance;
|
||||
private readonly string _filesPath;
|
||||
|
||||
@@ -365,6 +365,23 @@ namespace Umbraco.Tests.Integration.Testing
|
||||
|
||||
break;
|
||||
case UmbracoTestOptions.Database.NewSchemaPerFixture:
|
||||
// If we try to AttachSchema before the old schema has been detached
|
||||
// the process will be blocked since readyQueue remain empty
|
||||
// Probably because the DB is blocked because it hasn't been detached
|
||||
// Also if we attach a new schema for every test isn't it just essentially
|
||||
// the same as NewSchemaPerTest?
|
||||
if (db.HasSchema)
|
||||
{
|
||||
// We must re-configure our current factory since attaching a new LocalDb from the pool changes connection strings
|
||||
if (!databaseFactory.Configured)
|
||||
{
|
||||
databaseFactory.Configure(db.ConnectionString, Constants.DatabaseProviders.SqlServer);
|
||||
}
|
||||
|
||||
// re-run the runtime level check
|
||||
runtimeState.DetermineRuntimeLevel();
|
||||
return;
|
||||
}
|
||||
|
||||
// New DB + Schema
|
||||
var newSchemaFixtureDbId = db.AttachSchema();
|
||||
|
||||
Reference in New Issue
Block a user