-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #283: Trying to reproduce error with unit test
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |