Skip to content

Commit

Permalink
Tests: handle JSON.NET schema validation limit exceeded.
Browse files Browse the repository at this point in the history
Copied from extras bucket
  • Loading branch information
r15ch13 committed May 27, 2017
1 parent a9dfea5 commit 139813a
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions test/Scoop-Manifest.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,32 @@ describe "manifest-validation" {
$manifest_files = gci $bucketdir *.json
$validator = new-object Scoop.Validator($schema, $true)
}

$global:quota_exceeded = $false

$manifest_files | % {
it "$_" {
$validator.Validate($_.fullname)
if ($validator.Errors.Count -gt 0) {
write-host -f yellow $validator.ErrorsAsString
$file = $_ # exception handling may overwrite $_

if(!($global:quota_exceeded)) {
try {
$validator.Validate($file.fullname)

if ($validator.Errors.Count -gt 0) {
write-host -f yellow $validator.ErrorsAsString
}
$validator.Errors.Count | should be 0
} catch {
if($_.exception.message -like '*The free-quota limit of 1000 schema validations per hour has been reached.*') {
$global:quota_exceeded = $true
write-host -f darkyellow 'Schema validation limit exceeded. Will skip further validations.'
} else {
throw
}
}
}
$validator.Errors.Count | should be 0

$manifest = parse_json $_.fullname
$manifest = parse_json $file.fullname
$url = arch_specific "url" $manifest "32bit"
$url64 = arch_specific "url" $manifest "64bit"
if(!$url) {
Expand Down

0 comments on commit 139813a

Please sign in to comment.