Skip to content

Commit

Permalink
Fixing flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
mathewc committed Apr 13, 2016
1 parent 70b86ab commit 44b6571
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/WebJobs.Script.Tests/FileTraceWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ await Task.WhenAll(
}

[Fact]
public void SetNewLogFile_PurgesOldLogFiles()
public async Task SetNewLogFile_PurgesOldLogFiles()
{
DirectoryInfo directory = new DirectoryInfo(_logFilePath);
directory.Create();
Expand Down Expand Up @@ -83,9 +83,14 @@ public void SetNewLogFile_PurgesOldLogFiles()

files = directory.GetFiles().OrderByDescending(p => p.LastWriteTime).ToArray();

await TestHelpers.Await(() =>
{
files = directory.GetFiles().OrderByDescending(p => p.LastWriteTime).ToArray();
return files.Length == 2;
}, timeout: 2000);

// verify the correct log files were purged and the 2
// most recent files were retained
Assert.Equal(2, files.Length);
Assert.True(files[0].Name.StartsWith("4"));
Assert.True(files[1].Name.StartsWith("3"));
}
Expand Down

0 comments on commit 44b6571

Please sign in to comment.