Skip to content

Commit

Permalink
Make SyncFixture users use seperate directories and clean them up
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Dec 10, 2024
1 parent ce28810 commit 6e8d198
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/FwLite/FwLiteProjectSync.Tests/Fixtures/SyncFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private SyncFixture(string projectName, string projectFolder)
_services = rootServiceProvider.CreateAsyncScope();
}

public SyncFixture(): this("sena-3_" + Guid.NewGuid().ToString("N"), "FwLiteSyncFixture")
public SyncFixture(): this("sena-3_" + Guid.NewGuid().ToString().Split("-")[0], "FwLiteSyncFixture" + Guid.NewGuid().ToString().Split("-")[0])
{
}

Expand All @@ -56,8 +56,19 @@ public async Task InitializeAsync()

public async Task DisposeAsync()
{
var dbContext = _services.ServiceProvider.GetRequiredService<LcmCrdtDbContext>();
await dbContext.Database.EnsureDeletedAsync(); // this is necessary or else the db is still in use when we try to delete the crdtProjectsFolder. Is that bad?

var projectsFolder = _services.ServiceProvider.GetRequiredService<IOptions<FwDataBridgeConfig>>().Value
.ProjectsFolder;
var crdtProjectsFolder =
_services.ServiceProvider.GetRequiredService<IOptions<LcmCrdtConfig>>().Value.ProjectPath;

await _services.DisposeAsync();
_cleanup.Dispose();

Directory.Delete(crdtProjectsFolder, true);
Directory.Delete(projectsFolder, true);
}

public CrdtMiniLcmApi CrdtApi { get; set; } = null!;
Expand Down

0 comments on commit 6e8d198

Please sign in to comment.