Skip to content

Commit

Permalink
setshould
Browse files Browse the repository at this point in the history
  • Loading branch information
freddydk committed Aug 8, 2023
1 parent 1cb3489 commit d06cd79
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Tests/VerifyPRChanges.Action.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,84 +15,84 @@ 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 `
-prBaseRepository "microsoft/AL-Go" `
-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 `
-prBaseRepository "microsoft/AL-Go" `
-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 `
-prBaseRepository "microsoft/AL-Go" `
-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 `
-prBaseRepository "microsoft/AL-Go" `
-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 `
-prBaseRepository "microsoft/AL-Go" `
-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 `
-prBaseRepository "microsoft/AL-Go" `
-pullRequestId "123456" `
-token "ABC"
} | Should -Throw
$host.SetShouldExit(0)
}

It 'should succeed if the PR is from a fork and changes an .al file' {
Expand Down Expand Up @@ -134,14 +134,14 @@ 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 `
-prBaseRepository "microsoft/AL-Go" `
-pullRequestId "123456" `
-token "ABC"
} | Should -Throw
$host.SetShouldExit(0)
}

It 'Compile Action' {
Expand Down

0 comments on commit d06cd79

Please sign in to comment.