update pester to 5.x (#6536)

This commit is contained in:
William Cheng 2020-06-04 15:05:08 +08:00 committed by GitHub
parent b2c615b253
commit 859e7f7228
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 117 additions and 106 deletions

View File

@ -32,7 +32,7 @@ install:
- git clone https://github.com/wing328/swagger-samples
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
- ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.3.1
- ps: Install-Module Pester -Force -Scope CurrentUser
build_script:
- dotnet --info
# build C# API client (netcore)

View File

@ -5,8 +5,8 @@ Describe -tag '{{{packageName}}}' -name '{{{apiNamePrefix}}}{{{classname}}}' {
Context '{{{vendorExtensions.x-powershell-method-name}}}' {
It 'Test {{{vendorExtensions.x-powershell-method-name}}}' {
#$TestResult = Invoke-PetApiGetPetById{{#allParams}} -{{{paramName}}} "TEST_VALUE"{{/allParams}}
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}

View File

@ -6,8 +6,8 @@ Describe -tag '{{{packageName}}}' -name '{{{apiNamePrefix}}}{{{classname}}}' {
It 'Initialize-{{{apiNamePrefix}}}{{{classname}}}' {
# a simple test to create an object
#$NewObject = Initialize-{{{apiNamePrefix}}}{{{classname}}}{{#vars}} -{{name}} "TEST_VALUE"{{/vars}}
#$NewObject | Should BeOfType {{classname}}
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType {{classname}}
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -31,3 +31,14 @@ src/PSPetstore/Private/PSApiClient.ps1
src/PSPetstore/Private/PSHttpSignatureAuth.ps1
src/PSPetstore/Private/PSRSAEncryptionProvider.cs
src/PSPetstore/en-US/about_PSPetstore.help.txt
tests/Api/PSPetApi.Tests.ps1
tests/Api/PSStoreApi.Tests.ps1
tests/Api/PSUserApi.Tests.ps1
tests/Model/ApiResponse.Tests.ps1
tests/Model/Category.Tests.ps1
tests/Model/InlineObject.Tests.ps1
tests/Model/InlineObject1.Tests.ps1
tests/Model/Order.Tests.ps1
tests/Model/Pet.Tests.ps1
tests/Model/Tag.Tests.ps1
tests/Model/User.Tests.ps1

View File

@ -3,7 +3,7 @@
#
# Generated by: OpenAPI Generator Team
#
# Generated on: 6/3/20
# Generated on: 6/4/20
#
@{

View File

@ -5,68 +5,68 @@
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
Describe -tag 'PSPetstore' -name 'PSPetApi' {
Describe -tag 'PSPetstore' -name 'PSPSPetApi' {
Context 'Add-PSPet' {
It 'Test Add-PSPet' {
#$TestResult = Invoke-PetApiGetPetById -Pet "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Remove-Pet' {
It 'Test Remove-Pet' {
#$TestResult = Invoke-PetApiGetPetById -PetId "TEST_VALUE" -ApiKey "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Find-PSPetsByStatus' {
It 'Test Find-PSPetsByStatus' {
#$TestResult = Invoke-PetApiGetPetById -Status "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Find-PSPetsByTags' {
It 'Test Find-PSPetsByTags' {
#$TestResult = Invoke-PetApiGetPetById -Tags "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Get-PSPetById' {
It 'Test Get-PSPetById' {
#$TestResult = Invoke-PetApiGetPetById -PetId "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Update-PSPet' {
It 'Test Update-PSPet' {
#$TestResult = Invoke-PetApiGetPetById -Pet "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Update-PSPetWithForm' {
It 'Test Update-PSPetWithForm' {
#$TestResult = Invoke-PetApiGetPetById -PetId "TEST_VALUE" -Name "TEST_VALUE" -Status "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Invoke-PSUploadFile' {
It 'Test Invoke-PSUploadFile' {
#$TestResult = Invoke-PetApiGetPetById -PetId "TEST_VALUE" -AdditionalMetadata "TEST_VALUE" -File "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}

View File

@ -5,36 +5,36 @@
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
Describe -tag 'PSPetstore' -name 'PSStoreApi' {
Describe -tag 'PSPetstore' -name 'PSPSStoreApi' {
Context 'Remove-PSOrder' {
It 'Test Remove-PSOrder' {
#$TestResult = Invoke-PetApiGetPetById -OrderId "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Get-PSInventory' {
It 'Test Get-PSInventory' {
#$TestResult = Invoke-PetApiGetPetById
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Get-PSOrderById' {
It 'Test Get-PSOrderById' {
#$TestResult = Invoke-PetApiGetPetById -OrderId "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Invoke-PSPlaceOrder' {
It 'Test Invoke-PSPlaceOrder' {
#$TestResult = Invoke-PetApiGetPetById -Order "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}

View File

@ -5,68 +5,68 @@
# Generated by OpenAPI Generator: https://openapi-generator.tech
#
Describe -tag 'PSPetstore' -name 'PSUserApi' {
Describe -tag 'PSPetstore' -name 'PSPSUserApi' {
Context 'New-PSUser' {
It 'Test New-PSUser' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'New-PSUsersWithArrayInput' {
It 'Test New-PSUsersWithArrayInput' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'New-PSUsersWithListInput' {
It 'Test New-PSUsersWithListInput' {
#$TestResult = Invoke-PetApiGetPetById -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Remove-PSUser' {
It 'Test Remove-PSUser' {
#$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Get-PSUserByName' {
It 'Test Get-PSUserByName' {
#$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Invoke-PSLoginUser' {
It 'Test Invoke-PSLoginUser' {
#$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE" -Password "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Invoke-PSLogoutUser' {
It 'Test Invoke-PSLogoutUser' {
#$TestResult = Invoke-PetApiGetPetById
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}
Context 'Update-PSUser' {
It 'Test Update-PSUser' {
#$TestResult = Invoke-PetApiGetPetById -Username "TEST_VALUE" -User "TEST_VALUE"
#$TestResult | Should BeOfType TODO
#$TestResult.property | Should Be 0
#$TestResult | Should -BeOfType TODO
#$TestResult.property | Should -Be 0
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSApiResponse' {
It 'Initialize-PSApiResponse' {
# a simple test to create an object
#$NewObject = Initialize-PSApiResponse -Code "TEST_VALUE" -Type "TEST_VALUE" -Message "TEST_VALUE"
#$NewObject | Should BeOfType ApiResponse
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType ApiResponse
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSCategory' {
It 'Initialize-PSCategory' {
# a simple test to create an object
#$NewObject = Initialize-PSCategory -Id "TEST_VALUE" -Name "TEST_VALUE"
#$NewObject | Should BeOfType Category
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType Category
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSInlineObject' {
It 'Initialize-PSInlineObject' {
# a simple test to create an object
#$NewObject = Initialize-PSInlineObject -Name "TEST_VALUE" -Status "TEST_VALUE"
#$NewObject | Should BeOfType InlineObject
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType InlineObject
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSInlineObject1' {
It 'Initialize-PSInlineObject1' {
# a simple test to create an object
#$NewObject = Initialize-PSInlineObject1 -AdditionalMetadata "TEST_VALUE" -File "TEST_VALUE"
#$NewObject | Should BeOfType InlineObject1
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType InlineObject1
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSOrder' {
It 'Initialize-PSOrder' {
# a simple test to create an object
#$NewObject = Initialize-PSOrder -Id "TEST_VALUE" -PetId "TEST_VALUE" -Quantity "TEST_VALUE" -ShipDate "TEST_VALUE" -Status "TEST_VALUE" -Complete "TEST_VALUE"
#$NewObject | Should BeOfType Order
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType Order
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSPet' {
It 'Initialize-PSPet' {
# a simple test to create an object
#$NewObject = Initialize-PSPet -Id "TEST_VALUE" -Category "TEST_VALUE" -Name "TEST_VALUE" -PhotoUrls "TEST_VALUE" -Tags "TEST_VALUE" -Status "TEST_VALUE"
#$NewObject | Should BeOfType Pet
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType Pet
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSTag' {
It 'Initialize-PSTag' {
# a simple test to create an object
#$NewObject = Initialize-PSTag -Id "TEST_VALUE" -Name "TEST_VALUE"
#$NewObject | Should BeOfType Tag
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType Tag
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -10,8 +10,8 @@ Describe -tag 'PSPetstore' -name 'PSUser' {
It 'Initialize-PSUser' {
# a simple test to create an object
#$NewObject = Initialize-PSUser -Id "TEST_VALUE" -Username "TEST_VALUE" -FirstName "TEST_VALUE" -LastName "TEST_VALUE" -Email "TEST_VALUE" -Password "TEST_VALUE" -Phone "TEST_VALUE" -UserStatus "TEST_VALUE"
#$NewObject | Should BeOfType User
#$NewObject.property | Should Be 0
#$NewObject | Should -BeOfType User
#$NewObject.property | Should -Be 0
}
}
}

View File

@ -23,21 +23,21 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
# Get
$Result = Get-PSPetById -petId $Id
$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."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"
$Result.GetType().fullname | Should -Be "System.Management.Automation.PSCustomObject"
# Update (form)
$Result = Update-PSPetWithForm -petId $Id -Name "PowerShell Update" -Status "Pending"
$Result = Get-PSPetById -petId $Id
$Result."id" | Should Be 38369
$Result."name" | Should Be "PowerShell Update"
$Result."status" | Should Be "Pending"
$Result."id" | Should -Be 38369
$Result."name" | Should -Be "PowerShell Update"
$Result."status" | Should -Be "Pending"
# Update (put)
$NewPet = Initialize-PSPet -Id $Id -Name 'PowerShell2' -Category (
@ -51,13 +51,13 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Result = Update-PSPet -Pet $NewPet
$Result = Get-PSPetById -petId $Id -WithHttpInfo
$Result.GetType().fullname | Should Be "System.Collections.Hashtable"
#$Result["Response"].GetType().fullanme | Should Be "System.Management.Automation.PSCustomObject"
$Result["Response"]."id" | Should Be 38369
$Result["Response"]."name" | Should Be "PowerShell2"
$Result["Response"]."status" | Should Be "Sold"
$Result["StatusCode"] | Should Be 200
$Result["Headers"]["Content-Type"] | Should Be "application/json"
$Result.GetType().fullname | Should -Be "System.Collections.Hashtable"
#$Result["Response"].GetType().fullanme | Should -Be "System.Management.Automation.PSCustomObject"
$Result["Response"]."id" | Should -Be 38369
$Result["Response"]."name" | Should -Be "PowerShell2"
$Result["Response"]."status" | Should -Be "Sold"
$Result["StatusCode"] | Should -Be 200
$Result["Headers"]["Content-Type"] | Should -Be "application/json"
# upload file
$file = Get-Item "./plus.gif"
@ -72,8 +72,8 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$Result = Update-PSPet -Pet $NewPet
$Result = Get-PSPetById -petId $NewPet."id" -WithHttpInfo
$Result["Response"]."id" | Should Be $NewPet."id"
$Result["Response"]."name" | Should Be $NewPet."name"
$Result["Response"]."id" | Should -Be $NewPet."id"
$Result["Response"]."name" | Should -Be $NewPet."name"
# Delete
$Result = Remove-Pet -petId $Id
@ -109,19 +109,19 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
# test find pets by tags
$Results = Find-PSPetsByTags 'bazbaz'
$Results.GetType().FullName| Should Be "System.Object[]"
$Results.Count | Should Be 2
$Results.GetType().FullName| Should -Be "System.Object[]"
$Results.Count | Should -Be 2
if ($Results[0]."id" -gt 10129) {
$Results[0]."id" | Should Be 20129
$Results[0]."id" | Should -Be 20129
} else {
$Results[0]."id" | Should Be 10129
$Results[0]."id" | Should -Be 10129
}
if ($Results[1]."id" -gt 10129) {
$Results[1]."id" | Should Be 20129
$Results[1]."id" | Should -Be 20129
} else {
$Results[1]."id" | Should Be 10129
$Results[1]."id" | Should -Be 10129
}
}
@ -132,22 +132,22 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
$HS = Get-PSHostSetting
$HS[0]["Url"] | Should Be "http://{server}.swagger.io:{port}/v2"
$HS[0]["Description"] | Should Be "petstore server"
$HS[0]["Variables"]["server"]["Description"] | Should Be "No description provided"
$HS[0]["Variables"]["server"]["DefaultValue"] | Should Be "petstore"
$HS[0]["Variables"]["server"]["EnumValues"] | Should Be @("petstore",
$HS[0]["Url"] | Should -Be "http://{server}.swagger.io:{port}/v2"
$HS[0]["Description"] | Should -Be "petstore server"
$HS[0]["Variables"]["server"]["Description"] | Should -Be "No description provided"
$HS[0]["Variables"]["server"]["DefaultValue"] | Should -Be "petstore"
$HS[0]["Variables"]["server"]["EnumValues"] | Should -Be @("petstore",
"qa-petstore",
"dev-petstore")
}
It "Get-PSUrlFromHostSetting tests" {
Get-PSUrlFromHostSetting -Index 0 | Should Be "http://petstore.swagger.io:80/v2"
Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "8080" } | Should Be "http://petstore.swagger.io:8080/v2"
Get-PSUrlFromHostSetting -Index 0 | Should -Be "http://petstore.swagger.io:80/v2"
Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "8080" } | Should -Be "http://petstore.swagger.io:8080/v2"
#Get-PSUrlFromHostSetting -Index 2 | Should -Throw -ExceptionType ([RuntimeException])
#Get-PSUrlFromHostSetting -Index 2 -ErrorAction Stop | Should -Throw "RuntimeException: Invalid index 2 when selecting the host. Must be less than 2"
#Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "1234" } -ErrorAction Stop | Should -Throw "RuntimeException: The variable 'port' in the host URL has invalid value 1234. Must be 80,8080"
#Get-PSUrlFromHostSetting -Index 2 -ErrorAction Stop | Should -Throw "RuntimeException: Invalid index 2 when selecting the host. Must -Be less than 2"
#Get-PSUrlFromHostSetting -Index 0 -Variables @{ "port" = "1234" } -ErrorAction Stop | Should -Throw "RuntimeException: The variable 'port' in the host URL has invalid value 1234. Must -Be 80,8080"
}
@ -156,16 +156,16 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
Set-PSConfigurationDefaultHeader -Key "TestKey" -Value "TestValue"
$Configuration = Get-PSConfiguration
$Configuration["DefaultHeaders"].Count | Should Be 1
$Configuration["DefaultHeaders"]["TestKey"] | Should Be "TestValue"
$Configuration["DefaultHeaders"].Count | Should -Be 1
$Configuration["DefaultHeaders"]["TestKey"] | Should -Be "TestValue"
}
It "Configuration tests" {
$Conf = Get-PSConfiguration
$Conf["SkipCertificateCheck"] | Should Be $false
$Conf["SkipCertificateCheck"] | Should -Be $false
$Conf = Set-PSConfiguration -PassThru -SkipCertificateCheck
$Conf["SkipCertificateCheck"] | Should Be $true
$Conf["SkipCertificateCheck"] | Should -Be $true
$Conf = Set-PSConfiguration -PassThru # reset SkipCertificateCheck
}
@ -179,10 +179,10 @@ Describe -tag 'PSOpenAPITools' -name 'Integration Tests' {
It "Create Object from JSON tests" {
$Result = ConvertFrom-PSJsonToPet '{"id": 345, "name": "json name test", "status": "available", "photoUrls": ["https://photo.test"]}'
$Result."id" | Should Be 345
$Result."name" | Should Be "json name test"
$Result."status" | Should Be "available"
$Result."photoUrls" | Should Be @("https://photo.test")
$Result."id" | Should -Be 345
$Result."name" | Should -Be "json name test"
$Result."status" | Should -Be "available"
$Result."photoUrls" | Should -Be @("https://photo.test")
}
}