Skip to content

Commit ee4540b

Browse files
committed
test: fix DownloaderTest to retry tempdir cleanup
1 parent a58864e commit ee4540b

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

Tests.Vpn.Service/DownloaderTest.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,28 @@ public void Setup()
231231
}
232232

233233
[TearDown]
234-
public void TearDown()
234+
public async Task TearDown()
235235
{
236-
Directory.Delete(_tempDir, true);
236+
const int maxAttempts = 10;
237+
for (var attempt = 1; attempt <= maxAttempts; attempt++)
238+
{
239+
try
240+
{
241+
Directory.Delete(_tempDir, true);
242+
return;
243+
}
244+
catch (IOException e)
245+
{
246+
await TestContext.Out.WriteLineAsync(
247+
$"failed to delete temp dir (attempt {attempt} of {maxAttempts}): {e.Message}");
248+
if (attempt == maxAttempts)
249+
{
250+
throw;
251+
}
252+
253+
await Task.Delay(100);
254+
}
255+
}
237256
}
238257

239258
private string _tempDir;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy