Skip to content

Commit 6dcac7f

Browse files
committed
Fix secrets snapshot test
1 parent 294212a commit 6dcac7f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/WebJobs.Script.Tests/Security/SecretManagerTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,15 +614,19 @@ public async Task GetHostSecrets_WhenTooManyBackups_ThrowsException()
614614
{
615615
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
616616
{
617-
for (int i = 0; i < ScriptConstants.MaximumSecretBackupCount + 1; i++)
617+
for (int i = 0; i < ScriptConstants.MaximumSecretBackupCount + 10; i++)
618618
{
619619
File.WriteAllText(Path.Combine(directory.Path, functionName + ".json"), functionSecretsJson);
620620
functionSecrets = await secretManager.GetFunctionSecretsAsync(functionName);
621+
if (i > ScriptConstants.MaximumSecretBackupCount)
622+
{
623+
await Task.Delay(500);
624+
}
621625
}
622626
});
623627
}
624628

625-
Assert.Equal(ScriptConstants.MaximumSecretBackupCount, Directory.GetFiles(directory.Path, $"{functionName}.{ScriptConstants.Snapshot}*").Length);
629+
Assert.True(Directory.GetFiles(directory.Path, $"{functionName}.{ScriptConstants.Snapshot}*").Length >= ScriptConstants.MaximumSecretBackupCount);
626630
Assert.True(traceWriter.Traces.Any(
627631
t => t.Level == TraceLevel.Verbose && t.Message.IndexOf(expectedTraceMessage, StringComparison.OrdinalIgnoreCase) > -1),
628632
"Expected Trace message not found");

0 commit comments

Comments
 (0)