Skip to content

Commit

Permalink
PrefetchTests: Unmount before deleting packs
Browse files Browse the repository at this point in the history
If we do not unmount, then the packs do not get deleted and we skip
writing the commit-graph due to no new packs, failing the test.

Signed-off-by: Derrick Stolee <[email protected]>
  • Loading branch information
derrickstolee committed Jun 17, 2019
1 parent a8d174d commit d1054d3
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ public void PrefetchFailsWhenItCannotRemoveAPrefetchIdxNewerThanBadPrefetchPack(
[TestCase, Order(8)]
public void PrefetchCleansUpStaleTempPrefetchPacks()
{
this.Enlistment.UnmountGVFS();

// Create stale packs and idxs in the temp folder
string stalePackContents = "StalePack";
string stalePackPath = Path.Combine(this.TempPackRoot, $"{PrefetchPackPrefix}-123456-{Guid.NewGuid().ToString("N")}.pack");
Expand Down Expand Up @@ -304,18 +306,24 @@ public void PrefetchCleansUpOphanedLockFiles()

this.fileSystem.CreateEmptyFile(graphLockPath);

// Unmount so we can delete the files.
this.Enlistment.UnmountGVFS();

// Force deleting the prefetch packs to make the prefetch non-trivial.
this.fileSystem.DeleteDirectory(this.PackRoot);
this.fileSystem.CreateDirectory(this.PackRoot);
this.fileSystem.CreateEmptyFile(midxLockPath);

// Re-mount so the post-fetch job runs
this.Enlistment.MountGVFS();

this.Enlistment.Prefetch("--commits");
this.PostFetchJobShouldComplete();

this.fileSystem.FileExists(graphLockPath).ShouldBeFalse();
this.fileSystem.FileExists(midxLockPath).ShouldBeFalse();
this.fileSystem.FileExists(graphPath).ShouldBeTrue();
this.fileSystem.FileExists(midxPath).ShouldBeTrue();
this.fileSystem.FileExists(graphLockPath).ShouldBeFalse(nameof(graphLockPath));
this.fileSystem.FileExists(midxLockPath).ShouldBeFalse(nameof(midxLockPath));
this.fileSystem.FileExists(graphPath).ShouldBeTrue(nameof(graphPath));
this.fileSystem.FileExists(midxPath).ShouldBeTrue(nameof(midxPath));
}

private void PackShouldHaveIdxFile(string pathPath)
Expand Down

0 comments on commit d1054d3

Please sign in to comment.