Skip to content

Commit

Permalink
Issue #283: Trying to reproduce error with unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbra committed Oct 9, 2023
1 parent 5855c72 commit 6a8181c
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions unittests/Oracle/Oracle_specific/Issue283_Ora00922.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Dapper;
using FluentAssertions;
using grate.Configuration;
using grate.Migration;
using Oracle.TestInfrastructure;
using TestCommon.Generic.Running_MigrationScripts;
using TestCommon.TestInfrastructure;
using static grate.Configuration.KnownFolderKeys;

namespace Oracle.Oracle_specific;

public class Issue283_Ora00922: MigrationsScriptsBase
{
private const string problematicSql = @"
CREATE TABLE actor (
actor_id numeric NOT NULL ,
first_name VARCHAR(45) NOT NULL,
last_name VARCHAR(45) NOT NULL,
last_update DATE NOT NULL,
CONSTRAINT pk_actor PRIMARY KEY (actor_id)
);";


protected override IGrateTestContext Context => GrateTestContext.Oracle;

[Test]
public async Task Are_not_run_more_than_once_when_unchanged()
{
var db = TestConfig.RandomDatabase();
GrateMigrator? migrator;

var parent = CreateRandomTempDirectory();
var knownFolders = FoldersConfiguration.Default();

const string scriptName = "crate-table-actor.sql";

var upFolder = Wrap(parent, knownFolders[Up]!.Path);
WriteSql(upFolder, scriptName, problematicSql);

await using (migrator = Context.GetMigrator(db, parent, knownFolders))
{
await migrator.Migrate();
}

string[] scripts;
string sql = $"SELECT script_name FROM {Context.Syntax.TableWithSchema("grate", "ScriptsRun")}";

await using (var conn = Context.CreateDbConnection(db))
{
scripts = (await conn.QueryAsync<string>(sql)).ToArray();
}

scripts.Should().HaveCount(1);
scripts.First().Should().Be(scriptName);
}

}

0 comments on commit 6a8181c

Please sign in to comment.