Skip to content

Commit

Permalink
Handle needing to delete multiple LexBox projects
Browse files Browse the repository at this point in the history
  • Loading branch information
rmunn committed Aug 22, 2024
1 parent 1eea903 commit 0d1e52f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/LfMerge.Core.Tests/E2E/E2ETestBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Autofac;
Expand All @@ -23,7 +24,7 @@ public class E2ETestBase
public TemporaryFolder TestDataFolder { get; set; }
public TemporaryFolder LcmDataFolder { get; set; }
public string Sena3ZipPath { get; set; }
private Guid? ProjectIdToDelete { get; set; }
private readonly HashSet<Guid> ProjectIdsToDelete = [];
public SRTestEnvironment TestEnv { get; set; }

public MongoConnectionDouble _mongoConnection;
Expand Down Expand Up @@ -99,12 +100,13 @@ public async Task TestTeardown()
var success = outcome == ResultState.Success || outcome == ResultState.Ignored;
// Only delete temp folder if test passed, otherwise we'll want to leave it in place for post-test investigation
TestEnv.DeleteTempFolderDuringCleanup = success;
// Also leave LexBox project in place for post-test investigation, even though this might tend to clutter things up a little
if (success && ProjectIdToDelete is not null) {
var projId = ProjectIdToDelete.Value;
ProjectIdToDelete = null;
await TestEnv.DeleteLexBoxProject(projId);
// On failure, also leave LexBox project(s) in place for post-test investigation, even though this might tend to clutter things up a little
if (success) {
foreach (var projId in ProjectIdsToDelete) {
await TestEnv.DeleteLexBoxProject(projId);
}
}
ProjectIdsToDelete.Clear();
TestEnv.Dispose();
}

Expand Down Expand Up @@ -162,7 +164,7 @@ public async Task<string> CreateEmptyFlexProjectInLexbox()
var result = await TestEnv.CreateLexBoxProject(testCode, randomGuid);
var pushUrl = SRTestEnvironment.LexboxUrlForProjectWithAuth(testCode).AbsoluteUri;
MercurialTestHelper.HgPush(testPath, pushUrl);
ProjectIdToDelete = result.Id;
if (result.Id.HasValue) ProjectIdsToDelete.Add(result.Id.Value);
return testCode;
}

Expand All @@ -174,7 +176,7 @@ public async Task<string> CreateNewProjectFromTemplate(string origZipPath)
// Now create project in LexBox
var result = await TestEnv.CreateLexBoxProject(testCode, randomGuid);
await TestEnv.ResetAndUploadZip(testCode, origZipPath);
ProjectIdToDelete = result.Id;
if (result.Id.HasValue) ProjectIdsToDelete.Add(result.Id.Value);
return testCode;
}

Expand Down

0 comments on commit 0d1e52f

Please sign in to comment.