Skip to content

Commit 973fc48

Browse files
committed
chore: Made test for sql serve schema issue sql-server specific. I suspect the failing tests indicate the bug is still present on other DBMS's, but I don't know enough to go chasing that right now.
1 parent 53b3eb5 commit 973fc48

File tree

3 files changed

+37
-30
lines changed

3 files changed

+37
-30
lines changed

grate.unittests/Generic/Running_MigrationScripts/Versioning_The_Database.cs

+1-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Collections.Generic;
1+
using System.Collections.Generic;
22
using System.Linq;
33
using System.Threading.Tasks;
44
using Dapper;
@@ -101,32 +101,4 @@ public async Task Creates_A_New_Version_In_Progress()
101101
version.status.Should().Be(MigrationStatus.InProgress);
102102
}
103103

104-
[Test]
105-
public async Task Bug230_Uses_Server_Casing_Rules_For_Schema()
106-
{
107-
//for bug #230 - when targeting an existing schema use the servers casing rules, not .Net's
108-
var db = TestConfig.RandomDatabase();
109-
var parent = CreateRandomTempDirectory();
110-
var knownFolders = FoldersConfiguration.Default(null);
111-
112-
CreateDummySql(parent, knownFolders[Sprocs]); // make sure there's something that could be logged...
113-
114-
await using (var migrator = Context.GetMigrator(db, parent, knownFolders))
115-
{
116-
await migrator.Migrate();
117-
Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `grate` schema.
118-
}
119-
120-
// Now we'll run again with the same name but different cased schema
121-
var grateConfig = Context.GetConfiguration(db, parent, knownFolders) with
122-
{
123-
SchemaName = "GRATE"
124-
};
125-
126-
await using (var migrator = Context.GetMigrator(grateConfig))
127-
{
128-
await migrator.Migrate(); // should either reuse the existing schema if a case-insensitive server, or create a new second schema for use if case-sensitive.
129-
Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `GRATE` schema, which may be the same as 'grate' depending on server settings.
130-
}
131-
}
132104
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,47 @@
1+
using System.Threading.Tasks;
2+
using grate.Configuration;
13
using grate.unittests.TestInfrastructure;
24
using NUnit.Framework;
35

6+
using static grate.Configuration.KnownFolderKeys;
7+
48
namespace grate.unittests.SqlServer.Running_MigrationScripts;
59

610
[TestFixture]
711
[Category("SqlServer")]
12+
[NonParallelizable]
813
// ReSharper disable once InconsistentNaming
914
public class Versioning_The_Database: Generic.Running_MigrationScripts.Versioning_The_Database
1015
{
1116
protected override IGrateTestContext Context => GrateTestContext.SqlServer;
17+
18+
19+
[Test]
20+
public async Task Bug230_Uses_Server_Casing_Rules_For_Schema()
21+
{
22+
//for bug #230 - when targeting an existing schema use the servers casing rules, not .Net's
23+
var db = TestConfig.RandomDatabase();
24+
var parent = CreateRandomTempDirectory();
25+
var knownFolders = FoldersConfiguration.Default(null);
26+
27+
CreateDummySql(parent, knownFolders[Sprocs]); // make sure there's something that could be logged...
28+
29+
await using (var migrator = Context.GetMigrator(db, parent, knownFolders))
30+
{
31+
await migrator.Migrate();
32+
Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `grate` schema.
33+
}
34+
35+
// Now we'll run again with the same name but different cased schema
36+
var grateConfig = Context.GetConfiguration(db, parent, knownFolders) with
37+
{
38+
SchemaName = "GRATE"
39+
};
40+
41+
await using (var migrator = Context.GetMigrator(grateConfig))
42+
{
43+
await migrator.Migrate(); // should either reuse the existing schema if a case-insensitive server, or create a new second schema for use if case-sensitive.
44+
Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `GRATE` schema, which may be the same as 'grate' depending on server settings.
45+
}
46+
}
1247
}

grate.unittests/SqlServerCaseSensitive/Running_MigrationScripts/Versioning_The_Database.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace grate.unittests.SqlServerCaseSensitive.Running_MigrationScripts
66
[TestFixture]
77
[Category("SqlServerCaseSensitive")]
88
// ReSharper disable once InconsistentNaming
9-
public class Versioning_The_Database : Generic.Running_MigrationScripts.Versioning_The_Database
9+
public class Versioning_The_Database : grate.unittests.SqlServer.Running_MigrationScripts.Versioning_The_Database
1010
{
1111
protected override IGrateTestContext Context => GrateTestContext.SqlServerCaseSensitive;
1212
}

0 commit comments

Comments
 (0)