Skip to content

Commit

Permalink
WIP: Think all works now
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbra committed Mar 9, 2024
1 parent e2d3d40 commit d0102aa
Show file tree
Hide file tree
Showing 75 changed files with 379 additions and 325 deletions.
6 changes: 6 additions & 0 deletions unittests/Basic_tests/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Basic_tests;

// ReSharper disable once UnusedType.Global
public class Startup
{
}
25 changes: 25 additions & 0 deletions unittests/CommandLine/CommandLine.Common/Startup_T.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using CommandLine.Common.TestInfrastructure;
using grate.Configuration;
using grate.Migration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TestCommon.TestInfrastructure;

namespace CommandLine.Common;

// ReSharper disable once UnusedType.Global
public abstract class Startup<
TTestContainerDatabase,
TExternalDatabase,
TGrateTestContext>: TestCommon.Startup<TTestContainerDatabase, TExternalDatabase, TGrateTestContext>
where TTestContainerDatabase : ITestDatabase
where TExternalDatabase : ITestDatabase
where TGrateTestContext : IGrateTestContext
{
protected abstract DatabaseType DatabaseType { get; }

protected override void ConfigureExtraServices(IServiceCollection services, HostBuilderContext context)
{
services.AddSingleton<IGrateMigrator>(new CommandLineGrateMigrator(DatabaseType));
}
}
5 changes: 1 addition & 4 deletions unittests/CommandLine/CommandLine.MariaDB/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
namespace CommandLine.MariaDB;

// ReSharper disable once UnusedType.Global
public class Startup: TestCommon.Startup
public class Startup: CommandLine.Common.Startup<MariaDbTestContainerDatabase, MariaDBExternalDatabase, MariaDbGrateTestContext>
{
protected override DatabaseType DatabaseType => DatabaseType.MariaDB;
protected override Type TestContainerDatabaseType => typeof(MariaDbTestContainerDatabase);
protected override Type ExternalTestDatabaseType => typeof(MariaDBExternalDatabase);
protected override Type TestContextType => typeof(MariaDbGrateTestContext);
}
5 changes: 2 additions & 3 deletions unittests/CommandLine/CommandLine.Oracle/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using grate.Configuration;
using Oraclde.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace CommandLine.Oracle;

// ReSharper disable once UnusedType.Global
public class Startup: TestCommon.Startup
public class Startup: Common.Startup<OracleTestContainerDatabase, OracleExternalDatabase, OracleGrateTestContext>
{
protected override DatabaseType DatabaseType => DatabaseType.Oracle;
protected override Type TestContainerDatabaseType => typeof(OracleTestContainerDatabase);
protected override Type TestContextType => typeof(OracleGrateTestContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CommandLine.PostgreSQL.Running_MigrationScripts;

[Collection(nameof(PostgreSqlTestContainer))]
[Collection(nameof(PostgreSqlTestContainerDatabase))]
// ReSharper disable once InconsistentNaming
public class Failing_Scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Failing_Scripts(testContext, testOutput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace CommandLine.PostgreSQL.Running_MigrationScripts;

[Collection(nameof(PostgreSqlTestContainer))]
[Collection(nameof(PostgreSqlTestContainerDatabase))]
// ReSharper disable once InconsistentNaming
public class One_time_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.One_time_scripts(testContext, testOutput)
Expand Down
4 changes: 1 addition & 3 deletions unittests/CommandLine/CommandLine.PostgreSQL/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace CommandLine.PostgreSQL;

// ReSharper disable once UnusedType.Global
public class Startup: TestCommon.Startup
public class Startup: Common.Startup<PostgreSqlTestContainerDatabase, PostgreSqlExternalDatabase, PostgreSqlGrateTestContext>
{
protected override DatabaseType DatabaseType => DatabaseType.PostgreSQL;
protected override Type TestContainerDatabaseType => typeof(PostgreSqlTestContainer);
protected override Type TestContextType => typeof(PostgreSqlGrateTestContext);
}
5 changes: 1 addition & 4 deletions unittests/CommandLine/CommandLine.SqlServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
namespace CommandLine.SqlServer;

// ReSharper disable once UnusedType.Global
public class Startup: CommandLine.Common.Startup
public class Startup: Common.Startup<SqlServerTestContainerDatabase, SqlServerExternalDatabase, SqlServerGrateTestContext>
{
protected override DatabaseType DatabaseType => DatabaseType.SQLServer;
protected override Type TestContainerDatabaseType => typeof(SqlServerTestContainerDatabase);
protected override Type ExternalTestDatabaseType => typeof(SqlServerExternalDatabase);
protected override Type TestContextType => typeof(SqlServerGrateTestContext);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace CommandLine.Sqlite.Running_MigrationScripts;

[Collection(nameof(SqliteTestContainerDatabase))]
[Collection(nameof(SqliteTestDatabase))]
// ReSharper disable once InconsistentNaming
public class Failing_Scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Failing_Scripts(testContext, testOutput)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace CommandLine.Sqlite.Running_MigrationScripts;

[Collection(nameof(SqliteTestContainerDatabase))]
[Collection(nameof(SqliteTestDatabase))]
// ReSharper disable once InconsistentNaming
public class One_time_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.One_time_scripts(testContext, testOutput)
Expand Down
5 changes: 1 addition & 4 deletions unittests/CommandLine/CommandLine.Sqlite/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
namespace CommandLine.Sqlite;

// ReSharper disable once UnusedType.Global
public class Startup: TestCommon.Startup
public class Startup: CommandLine.Common.Startup<SqliteTestDatabase, SqliteTestDatabase, SqliteGrateTestContext>
{
protected override DatabaseType DatabaseType => DatabaseType.SQLite;
protected override Type TestContainerDatabaseType => typeof(SqliteTestContainerDatabase);
protected override Type ExternalTestDatabaseType { get; }
protected override Type TestContextType => typeof(SqliteGrateTestContext);
}
4 changes: 2 additions & 2 deletions unittests/MariaDB/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace MariaDB;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once UnusedType.Global
public class Database(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Database(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: GenericDatabase(testContext, testOutput);

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using TestCommon.TestInfrastructure;
namespace MariaDB.DependencyInjection;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once UnusedType.Global
public class ServiceCollectionTest(IGrateTestContext context)
public class ServiceCollectionTest(MariaDbGrateTestContext context)
: TestCommon.DependencyInjection.GrateServiceCollectionTest(context);
4 changes: 2 additions & 2 deletions unittests/MariaDB/MigrationTables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

namespace MariaDB;

//[Collection(nameof(MariaDbTestContainer))]
public class MigrationTables(IGrateTestContext testContext, ITestOutputHelper testOutput) :
[Collection(nameof(MariaDbGrateTestContext))]
public class MigrationTables(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput) :
GenericMigrationTables(testContext, testOutput);
4 changes: 2 additions & 2 deletions unittests/MariaDB/Running_MigrationScripts/Anytime_scripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Anytime_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Anytime_scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Anytime_scripts(testContext, testOutput);
4 changes: 2 additions & 2 deletions unittests/MariaDB/Running_MigrationScripts/DropDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once UnusedType.Global
public class DropDatabase(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class DropDatabase(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.DropDatabase(testContext, testOutput);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Environment_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Environment_scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Environment_scripts(testContext, testOutput);
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Everytime_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Everytime_scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Everytime_scripts(testContext, testOutput);
4 changes: 2 additions & 2 deletions unittests/MariaDB/Running_MigrationScripts/Failing_Scripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Failing_Scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Failing_Scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Failing_Scripts(testContext, testOutput)
{
protected override string ExpectedErrorMessageForInvalidSql =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class One_time_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class One_time_scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.One_time_scripts(testContext, testOutput);

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Order_Of_Scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Order_Of_Scripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Order_Of_Scripts(testContext, testOutput);

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
public class ScriptsRun_Table(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(MariaDbGrateTestContext))]
public class ScriptsRun_Table(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.ScriptsRun_Table(testContext, testOutput);
4 changes: 2 additions & 2 deletions unittests/MariaDB/Running_MigrationScripts/TokenScripts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
public class TokenScripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(MariaDbGrateTestContext))]
public class TokenScripts(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.TokenScripts(testContext, testOutput);

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace MariaDB.Running_MigrationScripts;

//[Collection(nameof(MariaDbTestContainer))]
[Collection(nameof(MariaDbGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Versioning_The_Database(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Versioning_The_Database(MariaDbGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Versioning_The_Database(testContext, testOutput);


Expand Down
7 changes: 4 additions & 3 deletions unittests/Oracle/Database.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using TestCommon.Generic;
using Oracle.TestInfrastructure;
using TestCommon.Generic;
using TestCommon.TestInfrastructure;

namespace Oracle;

[Collection(nameof(OracleTestContainerDatabase))]
public class Database(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class Database(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: GenericDatabase(testContext, testOutput);
5 changes: 3 additions & 2 deletions unittests/Oracle/DependencyInjection/ServiceCollectionTest.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using grate.Infrastructure;
using grate.Oracle.Migration;
using Oracle.TestInfrastructure;
using TestCommon.DependencyInjection;
using TestCommon.TestInfrastructure;

namespace Oracle.DependencyInjection;

[Collection(nameof(OracleTestContainerDatabase))]
public class ServiceCollectionTest(IGrateTestContext testContext)
[Collection(nameof(OracleGrateTestContext))]
public class ServiceCollectionTest(OracleGrateTestContext testContext)
: GrateServiceCollectionTest(testContext)
{
protected virtual Type DatabaseType => typeof(OracleDatabase);
Expand Down
5 changes: 3 additions & 2 deletions unittests/Oracle/MigrationTables.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using grate.Configuration;
using Oracle.TestInfrastructure;
using TestCommon.Generic;
using TestCommon.TestInfrastructure;

namespace Oracle;

[Collection(nameof(OracleTestContainerDatabase))]
public class MigrationTables(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class MigrationTables(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: GenericMigrationTables(testContext, testOutput)
{

Expand Down
7 changes: 4 additions & 3 deletions unittests/Oracle/Running_MigrationScripts/Anytime_scripts.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;

[Collection(nameof(OracleTestContainerDatabase))]
[Collection(nameof(OracleGrateTestContext))]
// ReSharper disable once InconsistentNaming
public class Anytime_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
public class Anytime_scripts(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Anytime_scripts(testContext, testOutput);

7 changes: 4 additions & 3 deletions unittests/Oracle/Running_MigrationScripts/DropDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;

// ReSharper disable once UnusedType.Global
[Collection(nameof(OracleTestContainerDatabase))]
public class DropDatabase(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class DropDatabase(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.DropDatabase(testContext, testOutput);
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;

// ReSharper disable once UnusedType.Global
[Collection(nameof(OracleTestContainerDatabase))]
public class Environment_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class Environment_scripts(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Environment_scripts(testContext, testOutput);

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;

[Collection(nameof(OracleTestContainerDatabase))]
public class Everytime_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class Everytime_scripts(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Everytime_scripts(testContext, testOutput);

7 changes: 4 additions & 3 deletions unittests/Oracle/Running_MigrationScripts/Failing_Scripts.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;

[Collection(nameof(OracleTestContainerDatabase))]
public class Failing_Scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class Failing_Scripts(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.Failing_Scripts(testContext, testOutput)
{
protected override string ExpectedErrorMessageForInvalidSql =>
Expand Down
7 changes: 4 additions & 3 deletions unittests/Oracle/Running_MigrationScripts/One_time_scripts.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using TestCommon.TestInfrastructure;
using Oracle.TestInfrastructure;
using TestCommon.TestInfrastructure;

namespace Oracle.Running_MigrationScripts;


[Collection(nameof(OracleTestContainerDatabase))]
public class One_time_scripts(IGrateTestContext testContext, ITestOutputHelper testOutput)
[Collection(nameof(OracleGrateTestContext))]
public class One_time_scripts(OracleGrateTestContext testContext, ITestOutputHelper testOutput)
: TestCommon.Generic.Running_MigrationScripts.One_time_scripts(testContext, testOutput)
{
protected override string CreateView1 => base.CreateView1 + " FROM DUAL";
Expand Down
Loading

0 comments on commit d0102aa

Please sign in to comment.