diff --git a/Tests/VerifyPRChanges.Action.Test.ps1 b/Tests/VerifyPRChanges.Action.Test.ps1 index 0c5465edb..25710c5f5 100644 --- a/Tests/VerifyPRChanges.Action.Test.ps1 +++ b/Tests/VerifyPRChanges.Action.Test.ps1 @@ -15,7 +15,6 @@ Describe 'VerifyPRChanges Action Tests' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename": "Scripts/BuildScript.ps1", "status": "modified"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -23,13 +22,13 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should fail if the PR is from a fork and adds a script' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename":"Scripts/BuildScript.ps1", "status": "added"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -37,13 +36,13 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should fail if the PR is from a fork and removes a script' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename":"Scripts/BuildScript.ps1","status":"removed"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -51,13 +50,13 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should fail if the PR is from a fork and changes the CODEOWNERS file' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename":"CODEOWNERS","status":"modified"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -65,13 +64,13 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should fail if the PR is from a fork and changes anything in the .github folder' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename":".github/Settings.json","status":"modified"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -79,13 +78,13 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should fail if the PR is from a fork and changes a yml file' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 1 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock -CommandName Invoke-WebRequest -MockWith { '[{"filename":".github/workflows/test.yaml","status":"modified"}]' } -ParameterFilter { $Uri -and $Uri -match "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -93,6 +92,7 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'should succeed if the PR is from a fork and changes an .al file' { @@ -134,7 +134,6 @@ Describe 'VerifyPRChanges Action Tests' { It 'should fail if the PR is from a fork and changes more than 3000 files' { Mock -CommandName Invoke-WebRequest -MockWith { '{ "changed_files": 5001 }' } -ParameterFilter { $Uri -and $Uri -notmatch "/files"} Mock Write-Host {} - Mock $host.SetShouldExit() {} { & $scriptPath ` @@ -142,6 +141,7 @@ Describe 'VerifyPRChanges Action Tests' { -pullRequestId "123456" ` -token "ABC" } | Should -Throw + $host.SetShouldExit(0) } It 'Compile Action' {