From d8517c6fdba74b9dde45654f8a46844751ee2f1d Mon Sep 17 00:00:00 2001
From: Howard Wolosky <HowardWolosky@users.noreply.github.com>
Date: Sat, 18 Jul 2020 16:24:35 -0700
Subject: [PATCH] Minor UT fixes

---
 Tests/GitHubGists.tests.ps1        |  5 ++++-
 Tests/GitHubRepositories.tests.ps1 | 10 ++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Tests/GitHubGists.tests.ps1 b/Tests/GitHubGists.tests.ps1
index bc59b974..67e06ccf 100644
--- a/Tests/GitHubGists.tests.ps1
+++ b/Tests/GitHubGists.tests.ps1
@@ -309,7 +309,10 @@ try
         }
 
         AfterAll {
-            Remove-Item -Path $tempPath -Recurse -ErrorAction SilentlyContinue -Force
+            if (Get-Variable -Name tempPath -ErrorAction SilentlyContinue)
+            {
+                Remove-Item -Path $tempPath -Recurse -ErrorAction SilentlyContinue -Force
+            }
         }
 
         Context 'Download gist content' {
diff --git a/Tests/GitHubRepositories.tests.ps1 b/Tests/GitHubRepositories.tests.ps1
index eb4bc666..74599da4 100644
--- a/Tests/GitHubRepositories.tests.ps1
+++ b/Tests/GitHubRepositories.tests.ps1
@@ -1271,6 +1271,11 @@ try
     Describe 'GitHubRepositories\Disable-GitHubRepositoryVulnerabilityAlert' {
         BeforeAll {
             $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid)
+
+            # The CI build has been unreliable with this test.
+            # Adding a short sleep to ensure successive queries reflect updated state.
+            Start-Sleep -Seconds $script:defaultSleepSecondsForReliability
+
             Enable-GitHubRepositoryVulnerabilityAlert -Uri  $repo.svn_url
         }
 
@@ -1306,6 +1311,11 @@ try
     Describe 'GitHubRepositories\Disable-GitHubRepositorySecurityFix' {
         BeforeAll {
             $repo = New-GitHubRepository -RepositoryName ([Guid]::NewGuid().Guid)
+
+            # The CI build has been unreliable with this test.
+            # Adding a short sleep to ensure successive queries reflect updated state.
+            Start-Sleep -Seconds $script:defaultSleepSecondsForReliability
+
             Enable-GitHubRepositorySecurityFix -Uri  $repo.svn_url
         }