fixes db testing context
This commit is contained in:
parent
9c24e4c66e
commit
7271649638
3 changed files with 35 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
|
|
||||||
|
|
@ -6,7 +7,7 @@ namespace test.Mandatory
|
||||||
[Collection("Database")]
|
[Collection("Database")]
|
||||||
[Trait("regres", "no")]
|
[Trait("regres", "no")]
|
||||||
[Trait("dev", "wip")]
|
[Trait("dev", "wip")]
|
||||||
public class Database: IClassFixture<ServerSideFixture>
|
public class Database: IClassFixture<ServerSideFixture>, IDisposable
|
||||||
{
|
{
|
||||||
ServerSideFixture _serverFixture;
|
ServerSideFixture _serverFixture;
|
||||||
ITestOutputHelper output;
|
ITestOutputHelper output;
|
||||||
|
|
@ -14,6 +15,8 @@ namespace test.Mandatory
|
||||||
{
|
{
|
||||||
this.output = output;
|
this.output = output;
|
||||||
_serverFixture = serverFixture;
|
_serverFixture = serverFixture;
|
||||||
|
if (_serverFixture.DbCreated)
|
||||||
|
_serverFixture.DropTestDb();
|
||||||
|
|
||||||
output.WriteLine($"Startup.DbSettings.Testing is {Startup.DbSettings.Testing}");
|
output.WriteLine($"Startup.DbSettings.Testing is {Startup.DbSettings.Testing}");
|
||||||
}
|
}
|
||||||
|
|
@ -25,11 +28,15 @@ namespace test.Mandatory
|
||||||
[Fact]
|
[Fact]
|
||||||
public void InstallFromScratchUsingPoweredNpgsqlUser()
|
public void InstallFromScratchUsingPoweredNpgsqlUser()
|
||||||
{
|
{
|
||||||
if (_serverFixture.DbCreated)
|
|
||||||
_serverFixture.DropTestDb();
|
|
||||||
|
|
||||||
_serverFixture.CreateTestDb();
|
_serverFixture.CreateTestDb();
|
||||||
_serverFixture.UpgradeDb();
|
_serverFixture.UpgradeDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_serverFixture.DbCreated)
|
||||||
|
_serverFixture.DropTestDb();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,9 @@ namespace test
|
||||||
_logger = value;
|
_logger = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DbCreated { get; private set; }
|
public bool DbCreated { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
public ServerSideFixture()
|
public ServerSideFixture()
|
||||||
{
|
{
|
||||||
|
|
@ -141,8 +141,6 @@ namespace test
|
||||||
cx.Close();
|
cx.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Needs a connection string parsing */
|
|
||||||
|
|
||||||
public void CreateTestDb()
|
public void CreateTestDb()
|
||||||
{
|
{
|
||||||
if (!DbCreated)
|
if (!DbCreated)
|
||||||
|
|
@ -157,6 +155,7 @@ namespace test
|
||||||
_logger.LogInformation($"database created.");
|
_logger.LogInformation($"database created.");
|
||||||
cx.Close();
|
cx.Close();
|
||||||
}
|
}
|
||||||
|
DbCreated=true;
|
||||||
}
|
}
|
||||||
public void DropTestDb()
|
public void DropTestDb()
|
||||||
{
|
{
|
||||||
|
|
@ -171,7 +170,9 @@ namespace test
|
||||||
_logger.LogInformation($"database dropped");
|
_logger.LogInformation($"database dropped");
|
||||||
cx.Close();
|
cx.Close();
|
||||||
}
|
}
|
||||||
|
DbCreated=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Logger.LogInformation("Disposing");
|
Logger.LogInformation("Disposing");
|
||||||
|
|
|
||||||
|
|
@ -29,14 +29,18 @@ namespace test
|
||||||
|
|
||||||
[Collection("Yavsc mandatory success story")]
|
[Collection("Yavsc mandatory success story")]
|
||||||
[Trait("regres", "no")]
|
[Trait("regres", "no")]
|
||||||
public class YavscMandatory: BaseTestContext, IClassFixture<ServerSideFixture>
|
public class YavscMandatory: BaseTestContext, IClassFixture<ServerSideFixture>, IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
ApplicationDbContext _dbContext;
|
ApplicationDbContext _dbContext;
|
||||||
|
ServerSideFixture _fixture;
|
||||||
|
|
||||||
public YavscMandatory(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
|
public YavscMandatory(ITestOutputHelper output, ServerSideFixture fixture) : base (output, fixture)
|
||||||
{
|
{
|
||||||
_dbContext = fixture.DbContext;
|
_dbContext = fixture.DbContext;
|
||||||
|
_fixture = fixture;
|
||||||
|
if (!_fixture.DbCreated)
|
||||||
|
_fixture.CreateTestDb();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -47,9 +51,12 @@ namespace test
|
||||||
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);
|
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);
|
||||||
if (!di.Exists) di.Create();
|
if (!di.Exists) di.Create();
|
||||||
|
|
||||||
|
|
||||||
var clone = new GitClone(_serverFixture.SiteSetup.GitRepository);
|
var clone = new GitClone(_serverFixture.SiteSetup.GitRepository);
|
||||||
clone.Launch(firstProject);
|
clone.Launch(firstProject);
|
||||||
|
gitRepo = di.FullName;
|
||||||
}
|
}
|
||||||
|
string gitRepo=null;
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
void AnsiToHtml()
|
void AnsiToHtml()
|
||||||
|
|
@ -67,7 +74,6 @@ namespace test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void MvcRazorHostAndParser()
|
public void MvcRazorHostAndParser()
|
||||||
{
|
{
|
||||||
|
|
@ -80,6 +86,7 @@ namespace test
|
||||||
void HaveHost()
|
void HaveHost()
|
||||||
{
|
{
|
||||||
beforeCompileContext = CreateYavscCompilationContext();
|
beforeCompileContext = CreateYavscCompilationContext();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
@ -186,5 +193,16 @@ namespace test
|
||||||
IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
|
IOptions<LocalizationOptions> localOptions = ActivatorUtilities.GetServiceOrCreateInstance<IOptions<LocalizationOptions>>(provider); ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (gitRepo!=null)
|
||||||
|
{
|
||||||
|
Directory.Delete(Path.Combine(gitRepo,"yavsc"), true);
|
||||||
|
}
|
||||||
|
if (_fixture.DbCreated)
|
||||||
|
_fixture.DropTestDb();
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue