Skip to content

Commit

Permalink
Rearrange tests, check path before move
Browse files Browse the repository at this point in the history
Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Aug 19, 2019
1 parent c1c0eb0 commit 22c1eb4
Showing 1 changed file with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,23 @@ public LooseObjectStepTests()
private string TempPackRoot => Path.Combine(this.PackRoot, TempPackFolder);

[TestCase]
[Order(3)]
[Order(1)]
public void NoLooseObjectsDoesNothing()
{
this.DeleteFiles(this.GetLooseObjectFiles());

this.DeleteFiles(this.GetLooseObjectFiles());
this.GetLooseObjectFiles().Count.ShouldEqual(0);
int startingPackFileCount = this.CountPackFiles();

this.Enlistment.LooseObjectStep();

this.GetLooseObjectFiles().Count.ShouldEqual(0);
this.CountPackFiles().ShouldEqual(startingPackFileCount);
}

[TestCase]
[Order(2)]
public void RemoveLooseObjectsInPackFiles()
{
this.ClearAllObjects();
Expand All @@ -49,7 +65,7 @@ public void RemoveLooseObjectsInPackFiles()
}

[TestCase]
[Order(4)]
[Order(3)]
public void PutLooseObjectsInPackFiles()
{
this.ClearAllObjects();
Expand All @@ -73,21 +89,7 @@ public void PutLooseObjectsInPackFiles()
}

[TestCase]
[Order(2)]
public void NoLooseObjectsDoesNothing()
{
this.DeleteFiles(this.GetLooseObjectFiles());
this.GetLooseObjectFiles().Count.ShouldEqual(0);
int startingPackFileCount = this.CountPackFiles();

this.Enlistment.LooseObjectStep();

this.GetLooseObjectFiles().Count.ShouldEqual(0);
this.CountPackFiles().ShouldEqual(startingPackFileCount);
}

[TestCase]
[Order(1)]
[Order(4)]
public void CorruptLooseObjectIsDeleted()
{
this.ClearAllObjects();
Expand Down Expand Up @@ -186,7 +188,14 @@ private void MovePackFilesToTemp()
{
string path2 = Path.Combine(this.TempPackRoot, Path.GetFileName(file));

File.Move(file, path2);
if (!File.Exists(path2))
{
File.Move(file, path2);
}
else
{
File.Delete(file);
}
}
}

Expand Down

0 comments on commit 22c1eb4

Please sign in to comment.