[PS][Experimental] Add tests for array of object in response (#5814)

* debugging array response

* fix find pet tests

* better tests to ignore order
This commit is contained in:
William Cheng
2020-04-03 20:12:11 +08:00
committed by GitHub
parent 281d154ff4
commit baeb1dd385
2 changed files with 73 additions and 10 deletions

View File

@@ -17,6 +17,17 @@ $Id = 38369
#$result = Update-PSPetWithForm
try {
$pet = Initialize-PSPet -Id $Id -Name 'foo' -Category (
Initialize-PSCategory -Id $Id -Name 'bar'
) -PhotoUrls @(
'http://example.com/foo',
'http://example.com/bar'
) -Tags (
Initialize-PSTag -Id 3 -Name 'baz'
) -Status Available
#Write-Host $pet
$Result = Add-PSPet -Pet $pet
Set-PSConfigurationApiKey -Id "api_key" -ApiKey "zzZZZZZZZZZZZZZ"
$result = Get-PSPetById -petId $Id -Verbose #-testHeader "testing only" -testQuery "testing something here"
} catch {
@@ -29,17 +40,22 @@ try {
#$result | Select-Object -Property "photoUrls" | ConvertTo-Json | Write-Host
#Write-Host "result =" + $result.photoUrls
#$pet = Initialize-Pet -Id 10129 -Name 'foo' -Category (
# Initialize-Category -Id 2 -Name 'bar'
#) -PhotoUrls @(
# 'http://example.com/foo',
# 'http://example.com/bar'
#) -Tags (
# Initialize-Tag -Id 3 -Name 'baz'
#) -Status Available
#
$pet2 = Initialize-PSPet -Id 20129 -Name '2foo' -Category (
Initialize-PSCategory -Id 20129 -Name '2bar'
) -PhotoUrls @(
'http://example.com/2foo',
'http://example.com/2bar'
) -Tags (
Initialize-PSTag -Id 3 -Name 'baz'
) -Status Available
#Write-Host $pet
#$Result = Invoke-PetApiAddPet -Body $pet
$Result = Add-PSPet -Pet $pet2
$Result = Find-PSPetsByTags 'baz'
Write-Host $Result.GetType().Name
Write-Host $Result
#$Result = Invoke-PetApiUpdatePetWithForm -petId $Id -Name "PowerShell Update" -Status "Pending"

View File

@@ -26,6 +26,8 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Result."id" | Should Be 38369
$Result."name" | Should Be "PowerShell"
$Result."status" | Should Be "Available"
$Result."category"."id" | Should Be $Id
$Result."category"."name" | Should Be 'PSCategory'
$Result.GetType().fullname | Should Be "System.Management.Automation.PSCustomObject"
@@ -65,6 +67,51 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Result = Remove-Pet -petId $Id
}
It 'Find pets test' {
# add 1st pet
$pet = Initialize-PSPet -Id 10129 -Name 'foo' -Category (
Initialize-PSCategory -Id 20129 -Name 'bar'
) -PhotoUrls @(
'http://example.com/foo',
'http://example.com/bar'
) -Tags (
Initialize-PSTag -Id 10129 -Name 'bazbaz'
) -Status Available
$Result = Add-PSPet -Pet $pet
# add 2nd pet
$pet2 = Initialize-PSPet -Id 20129 -Name '2foo' -Category (
Initialize-PSCategory -Id 20129 -Name '2bar'
) -PhotoUrls @(
'http://example.com/2foo',
'http://example.com/2bar'
) -Tags (
Initialize-PSTag -Id 10129 -Name 'bazbaz'
) -Status Available
$Result = Add-PSPet $pet2
# test find pets by tags
$Results = Find-PSPetsByTags 'bazbaz'
$Results.GetType().FullName| Should Be "System.Object[]"
$Results.Count | Should Be 2
if ($Results[0]."id" -gt 10129) {
$Results[0]."id" | Should Be 20129
} else {
$Results[0]."id" | Should Be 10129
}
if ($Results[1]."id" -gt 10129) {
$Results[1]."id" | Should Be 20129
} else {
$Results[1]."id" | Should Be 10129
}
}
}
Context 'Configuration' {