Skip to content

Commit d4db943

Browse files
committed
Revert running "deprecated" data migrations in all regression tests
1 parent dc8a637 commit d4db943

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

backend/FwLite/LcmCrdt.Tests/Data/DownloadProjectTests.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using Microsoft.EntityFrameworkCore;
22
using Microsoft.Extensions.DependencyInjection;
3-
using Microsoft.Extensions.Logging;
43
using SIL.Harmony.Core;
54

65
namespace LcmCrdt.Tests.Data;
@@ -13,7 +12,7 @@ public class DownloadProjectTests : IAsyncLifetime
1312

1413
public async Task InitializeAsync()
1514
{
16-
await _helper.InitializeAsync(RegressionTestHelper.RegressionVersion.v2);
15+
await _helper.InitializeAsync(RegressionTestHelper.RegressionVersion.v2, withDataMigrations: true);
1716
//add a change after migration which creates MorphTypes
1817
await _helper.Services.GetRequiredService<IMiniLcmApi>().CreateEntry(new Entry()
1918
{

backend/FwLite/LcmCrdt.Tests/Data/RegressionTestHelper.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,34 @@ private async Task InitDbFromScripts(RegressionVersion version)
3333
//need to close the connection, otherwise the collations won't get created, they would normally be created on open or save, so we're closing so they get created when EF opens the connection.
3434
await dbConnection.CloseAsync();
3535

36-
//setup again to trigger migrations
37-
await projectsService.SetupProjectContext(_crdtProject);
36+
await lcmCrdtDbContext.Database.MigrateAsync();
37+
38+
await projectsService.RefreshProjectData();
3839
}
3940

4041
public Task InitializeAsync()
4142
{
4243
return InitializeAsync(RegressionVersion.v2);
4344
}
4445

45-
public async Task InitializeAsync(RegressionVersion version)
46+
public async Task InitializeAsync(RegressionVersion version, bool withDataMigrations = false)
4647
{
4748
var builder = Host.CreateEmptyApplicationBuilder(null);
4849
builder.Services.AddTestLcmCrdtClient();
4950
_host = builder.Build();
5051
var services = _host.Services;
5152
_asyncScope = services.CreateAsyncScope();
5253
await InitDbFromScripts(version);
54+
55+
// Data migrations are already on their way out. It doesn't really make sense for all tests to run them,
56+
// which would change a bunch of verified project snapshots.
57+
// When data migrations are removed, we should run this code unconditionally
58+
// at the end of InitDbFromScripts (instead of the current db-migration and refresh-project-data approach)
59+
// Because that's closer to the prod code.
60+
if (withDataMigrations)
61+
{
62+
await Services.GetRequiredService<CurrentProjectService>().SetupProjectContext(_crdtProject);
63+
}
5364
}
5465

5566
public async Task DisposeAsync()

0 commit comments

Comments
 (0)