public void InvokeMgRollout_Returns_If_All_Scripts_Are_Applied() { ConfigManagerMock.ConfigReturns(null); DbMock.MigrationTableExists(true); ConfigManagerMock.RolloutDirectory("migrations/rollout"); FileManagerMock.GetAllFilesInFolder(new[] { "migrations/one.sql", "migrations/two.sql" }); DbMock.GetAppliedMigrations(new Migration[] { new() { Iteration = 1, MigrationId = "one.sql" }, new() { Iteration = 1, MigrationId = "two.sql" } });
public void InvokeMgRollout_Throws_If_Migration_Table_Does_Not_Exist_And_CreateTableIfNotExist_Is_False() { ConfigManagerMock.RolloutDirectory("migrations"); ConfigManagerMock.ConfigReturns(null); DbMock.MigrationTableExists(false); var command = new InvokeMgRollout(GetMockedDependencies()) { Database = "database", Host = "host", Port = 1111, Schema = "public", Username = "******" }; Assert.Throws <Exception>(() => command.Invoke()?.OfType <bool>()?.First()); }
public void InvokeMgRollout_Returns_If_No_Scripts_Found() { ConfigManagerMock.ConfigReturns(null); DbMock.MigrationTableExists(true); FileManagerMock.GetAllFilesInFolder(Array.Empty <string>()); ConfigManagerMock.RolloutDirectory("migrations/rollout"); var command = new InvokeMgRollout(GetMockedDependencies()) { Database = "database", Host = "host", Port = 1111, Schema = "public", Username = "******" }; var result = command.Invoke()?.OfType <MgResult>()?.First(); Assert.False(result.Successful); }
public void InvokeMgRollout_Creates_Migration_Table_If_CreateTableIfNotExist_Is_True() { ConfigManagerMock.ConfigReturns(null); ConfigManagerMock.RollbackDirectory("migrations/rollback"); DbMock.MigrationTableExists(false); DbMock.CreateMigrationTable(1); FileManagerMock.GetAllFilesInFolder(Array.Empty <string>()); ConfigManagerMock.RolloutDirectory("migrations/rollout"); var command = new InvokeMgRollout(GetMockedDependencies()) { Database = "database", Host = "host", Port = 1111, Schema = "public", Username = "******", CreateTableIfNotExist = true }; command.Invoke()?.OfType <string>()?.ToArray(); DbMock.VerifyCreateMigrationTable(Times.Once()); }