Skip to content

Commit

Permalink
bug erikbra#230: Added repro test for schema casing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wokket committed Sep 6, 2022
1 parent 2b5feb9 commit 4fec1c1
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,33 @@ public async Task Does_Not_Create_Versions_When_Dryrun()
var addedTable = await migrator.DbMigrator.Database.VersionTableExists();
Assert.False(addedTable); // we didn't even add the grate infrastructure
}

[Test]
public async Task Uses_Server_Casing_Rules_For_Schema()
{
//for bug #230 - when targeting an existing schema use the servers casing rules, not .Net's
var db = TestConfig.RandomDatabase();
var knownFolders = KnownFolders.In(CreateRandomTempDirectory());

CreateDummySql(knownFolders.Sprocs); // make sure there's something that could be logged...

var grateConfig = Context.GetConfiguration(db, knownFolders);
await using (var migrator = Context.GetMigrator(grateConfig))
{
await migrator.Migrate();

Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `grate` schema.
}
// Now we'll run again with the same name but different cased schema
grateConfig = Context.GetConfiguration(db, knownFolders) with
{
SchemaName = "GRATE"
};

await using (var migrator = Context.GetMigrator(grateConfig))
{
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.
Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `grate` schema.
}
}
}

0 comments on commit 4fec1c1

Please sign in to comment.