1.0.6-rc17

vnext
Paul Schneider 4 years ago
parent fedec6f6a2
commit 37263c12f3
4 changed files with 14 additions and 8 deletions

@ -41,7 +41,8 @@ namespace test
[Fact] [Fact]
public void GitClone() public void GitClone()
{ {
_serverFixture.EnsureTestDb(); Assert.True(_serverFixture.EnsureTestDb());
Assert.NotNull (_fixture.DbContext.Project);
var firstProject = _fixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault(); var firstProject = _fixture.DbContext.Project.Include(p=>p.Repository).FirstOrDefault();
Assert.NotNull (firstProject); Assert.NotNull (firstProject);
var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository); var di = new DirectoryInfo(_serverFixture.SiteSetup.GitRepository);

@ -5,7 +5,7 @@ using Xunit.Abstractions;
namespace test.Mandatory namespace test.Mandatory
{ {
[Collection("Database")] [Collection("Database")]
[Trait("regres", "yes")] [Trait("regres", "no")]
[Trait("dev", "wip")] [Trait("dev", "wip")]
public class Database: IClassFixture<ServerSideFixture>, IDisposable public class Database: IClassFixture<ServerSideFixture>, IDisposable
{ {

@ -155,6 +155,7 @@ namespace test
NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor)) NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor))
{ {
cx.Open(); cx.Open();
_logger.LogInformation($"check db for TestingDatabase:{TestingDatabase}");
var command = cx.CreateCommand(); var command = cx.CreateCommand();
command.CommandText = $"SELECT 1 FROM pg_database WHERE datname='{TestingDatabase}';"; command.CommandText = $"SELECT 1 FROM pg_database WHERE datname='{TestingDatabase}';";
dbCreated = (command.ExecuteScalar()!=null); dbCreated = (command.ExecuteScalar()!=null);
@ -165,19 +166,21 @@ namespace test
public bool EnsureTestDb() public bool EnsureTestDb()
{ {
CheckDbExistence(); if (!DbCreated)
if (!dbCreated)
{ {
using (NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor)) using (NpgsqlConnection cx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.DatabaseCtor))
{ {
_logger.LogInformation($"create database for TestingDatabase : {TestingDatabase}");
cx.Open(); cx.Open();
var command = cx.CreateCommand(); var command = cx.CreateCommand();
using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.Default)) using (NpgsqlConnection ownercx = new NpgsqlConnection(Startup.Testing.ConnectionStrings.Default))
command.CommandText = $"create database '{TestingDatabase}' OWNER = '{ownercx.UserName}';"; command.CommandText = $"create database \"{TestingDatabase}\" OWNER \"{ownercx.UserName}\";";
_logger.LogInformation(command.CommandText);
command.ExecuteNonQuery(); command.ExecuteNonQuery();
} }
dbCreated = DbContext.Database.EnsureCreated(); dbCreated = true;
} }
return dbCreated; return dbCreated;
} }
@ -194,7 +197,9 @@ namespace test
Logger.LogInformation("Disposing"); Logger.LogInformation("Disposing");
} }
public bool DbCreated { get { return dbCreated; } } public bool DbCreated { get {
CheckDbExistence();
return dbCreated; } }
} }
} }

@ -1 +1 @@
1.0.6-rc16 1.0.6-rc17

Loading…