-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
23 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
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
63 changes: 63 additions & 0 deletions
63
grate.unittests/Oracle/Running_MigrationScripts/With_batch_separator.cs
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,63 @@ | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Dapper; | ||
using FluentAssertions; | ||
using grate.Configuration; | ||
using grate.Migration; | ||
using grate.unittests.TestInfrastructure; | ||
using NUnit.Framework; | ||
using static grate.Configuration.KnownFolderKeys; | ||
|
||
namespace grate.unittests.Oracle.Running_MigrationScripts; | ||
|
||
[TestFixture] | ||
[Category("Oracle")] | ||
// ReSharper disable once InconsistentNaming | ||
public class With_batch_separator: Generic.Running_MigrationScripts.MigrationsScriptsBase | ||
{ | ||
protected override IGrateTestContext Context => GrateTestContext.Oracle; | ||
|
||
[Test()] | ||
public async Task Separates_multiple_statements() | ||
{ | ||
var db = TestConfig.RandomDatabase(); | ||
|
||
var parent = TestConfig.CreateRandomTempDirectory(); | ||
var knownFolders = FoldersConfiguration.Default(null); | ||
GrateMigrator? migrator; | ||
|
||
|
||
var path = new DirectoryInfo(Path.Combine(parent.ToString(), knownFolders[Up]!.Path)); | ||
const string filename = "multiple_statements.sql"; | ||
|
||
const string fileContent = @" | ||
create table table_one ( | ||
col number | ||
); | ||
/ | ||
create table table_two ( | ||
col number | ||
) | ||
"; | ||
|
||
WriteSql(path, filename, fileContent); | ||
|
||
await using (migrator = Context.GetMigrator(db, parent, knownFolders)) | ||
{ | ||
await migrator.Migrate(); | ||
} | ||
|
||
string[] scripts; | ||
string sql = $"SELECT text_of_script FROM {Context.Syntax.TableWithSchema("grate", "ScriptsRun")}"; | ||
|
||
await using (var conn = Context.CreateDbConnection(db)) | ||
{ | ||
scripts = (await conn.QueryAsync<string>(sql)).ToArray(); | ||
} | ||
|
||
scripts.Should().HaveCount(2); | ||
} | ||
|
||
} |
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
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