Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions samples/client/petstore/powershell-experimental/Test1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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' {
Expand Down