2019-05-24 20:14:38 +01:00
|
|
|
using System;
|
2018-09-04 16:40:02 +02:00
|
|
|
using Xunit;
|
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
|
|
2021-06-06 20:32:39 +01:00
|
|
|
namespace yavscTests.Mandatory
|
2018-09-04 16:40:02 +02:00
|
|
|
{
|
2019-01-05 02:51:04 +00:00
|
|
|
[Collection("Database")]
|
2021-04-05 00:11:54 +01:00
|
|
|
[Trait("regression", "II")]
|
2018-09-04 16:40:02 +02:00
|
|
|
[Trait("dev", "wip")]
|
2019-05-24 20:14:38 +01:00
|
|
|
public class Database: IClassFixture<ServerSideFixture>, IDisposable
|
2018-09-04 16:40:02 +02:00
|
|
|
{
|
2020-09-12 01:11:30 +01:00
|
|
|
readonly ServerSideFixture _serverFixture;
|
|
|
|
|
readonly ITestOutputHelper output;
|
2018-09-04 16:40:02 +02:00
|
|
|
public Database(ServerSideFixture serverFixture, ITestOutputHelper output)
|
|
|
|
|
{
|
|
|
|
|
this.output = output;
|
|
|
|
|
_serverFixture = serverFixture;
|
2021-01-02 00:41:54 +00:00
|
|
|
try {
|
2021-01-02 03:12:43 +00:00
|
|
|
if (_serverFixture.DbCreated)
|
|
|
|
|
|
2021-01-02 00:41:54 +00:00
|
|
|
_serverFixture.DropTestDb();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
output.WriteLine("db not dropped");
|
|
|
|
|
}
|
2021-06-06 20:32:39 +01:00
|
|
|
output.WriteLine($"Startup.Testing.ConnectionStrings.Default is {Startup.TestingSetup.ConnectionStrings.Default}");
|
2018-09-04 16:40:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Assuming we're using an account that may create databases,
|
|
|
|
|
/// Install all our migrations in a fresh new database.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Fact]
|
|
|
|
|
public void InstallFromScratchUsingPoweredNpgsqlUser()
|
|
|
|
|
{
|
2021-06-06 20:32:39 +01:00
|
|
|
Assert.True(_serverFixture.EnsureTestDb());
|
|
|
|
|
Assert.True(_serverFixture.UpgradeDb()==0);
|
2018-09-04 16:40:02 +02:00
|
|
|
}
|
2019-05-24 20:14:38 +01:00
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2021-06-06 22:38:04 +01:00
|
|
|
if (_serverFixture!=null)
|
|
|
|
|
{
|
|
|
|
|
_serverFixture.Dispose();
|
|
|
|
|
}
|
2019-05-24 20:14:38 +01:00
|
|
|
|
|
|
|
|
}
|
2018-09-04 16:40:02 +02:00
|
|
|
}
|
2019-01-05 02:51:04 +00:00
|
|
|
}
|