77# PSSwagger Module
88#
99# ########################################################################################
10+ $script :EnableTracer = $true
1011Import-Module (Join-Path " $PSScriptRoot " " TestUtilities.psm1" )
1112Describe " Basic API" - Tag ScenarioTest {
1213 BeforeAll {
@@ -25,6 +26,13 @@ Describe "Basic API" -Tag ScenarioTest {
2526 Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " Generated" | `
2627 Join-Path - ChildPath " Generated.Basic.Module" )
2728 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " PsSwaggerTestBasic" - TestRoutesFileName " PsSwaggerTestBasicRoutes.json" - Verbose
29+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
30+ $script :EnableTracer = $false
31+ Initialize-PSSwaggerDependencies - AcceptBootstrap
32+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
33+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
34+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
35+ }
2836 }
2937
3038 Context " Basic API tests" {
@@ -70,6 +78,13 @@ Describe "All Operations: Basic" -Tag ScenarioTest {
7078 Join-Path - ChildPath " Generated.TypesTest.Module" )
7179
7280 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " OperationTypes" - TestMiddlewareFileNames " OperationTypesMiddleware.js" - TestRoutesFileName " OperationTypesRoutes.json"
81+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
82+ $script :EnableTracer = $false
83+ Initialize-PSSwaggerDependencies - AcceptBootstrap
84+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
85+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
86+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
87+ }
7388 }
7489
7590 Context " All Operations: Basic tests" {
@@ -144,6 +159,13 @@ Describe "Get/List tests" -Tag ScenarioTest {
144159 Join-Path - ChildPath " Generated.GetList.Module" )
145160
146161 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " GetListTests" - TestRoutesFileName " GetListTestsRoutes.json"
162+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
163+ $script :EnableTracer = $false
164+ Initialize-PSSwaggerDependencies - AcceptBootstrap
165+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
166+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
167+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
168+ }
147169 }
148170
149171 Context " Get/List tests" {
@@ -178,12 +200,19 @@ Describe "Optional parameter tests" -Tag ScenarioTest {
178200 Write-Verbose " Importing modules"
179201 Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" | Join-Path - ChildPath " PSSwagger.Common.Helpers" | `
180202 Join-Path - ChildPath " PSSwagger.Common.Helpers.psd1" ) - Force
203+
181204 Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" | Join-Path - ChildPath " PSSwagger.Azure.Helpers" | `
182205 Join-Path - ChildPath " PSSwagger.Azure.Helpers.psd1" ) - Force
183206 Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " Generated" | `
184207 Join-Path - ChildPath " Generated.Optional.Module" )
185-
186208 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " OptionalParametersTests" - TestRoutesFileName " OptionalParametersTestsRoutes.json"
209+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
210+ $script :EnableTracer = $false
211+ Initialize-PSSwaggerDependencies - AcceptBootstrap
212+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
213+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
214+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
215+ }
187216 }
188217
189218 Context " Optional parameter tests" {
@@ -235,6 +264,13 @@ Describe "ParameterTypes tests" -Tag @('ParameterTypes','ScenarioTest') {
235264 Join-Path - ChildPath " Generated.ParamTypes.Module" )
236265
237266 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " ParameterTypes"
267+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
268+ $script :EnableTracer = $false
269+ Initialize-PSSwaggerDependencies - AcceptBootstrap
270+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
271+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
272+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
273+ }
238274 }
239275
240276 Context " ParameterTypes tests" {
@@ -381,6 +417,13 @@ Describe "AzureExtensions" {
381417 Join-Path - ChildPath " Generated.AzExt.Module" )
382418
383419 $processes = Start-JsonServer - TestRootPath $PSScriptRoot - TestApiName " AzureExtensions" - TestRoutesFileName " AzureExtensionsRoutes.json"
420+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
421+ $script :EnableTracer = $false
422+ Initialize-PSSwaggerDependencies - AcceptBootstrap
423+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
424+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
425+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
426+ }
384427 }
385428
386429 Context " AzureExtensions" {
@@ -578,7 +621,13 @@ Describe "AuthTests" -Tag @('Auth','ScenarioTest') {
578621 Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " Generated" | `
579622 Join-Path - ChildPath " Generated.ApiKeyQueryTest.Module" ) - Prefix " ApiKeyQuery"
580623
581-
624+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
625+ $script :EnableTracer = $false
626+ Initialize-PSSwaggerDependencies - AcceptBootstrap
627+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
628+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
629+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
630+ }
582631 }
583632
584633 Context " Basic Authentication" {
@@ -719,4 +768,37 @@ Describe "AuthTests" -Tag @('Auth','ScenarioTest') {
719768 }
720769 }
721770 }
771+ }
772+
773+ Describe " PSMetadataTests" - Tag @ (' PSMetadata' , ' ScenarioTest' ) {
774+ BeforeAll {
775+ Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" | Join-Path - ChildPath " PSSwagger.Common.Helpers" | `
776+ Join-Path - ChildPath " PSSwagger.Common.Helpers.psd1" ) - Force
777+ Initialize-Test - GeneratedModuleName " Generated.PSMetadataTest.Module" - TestApiName " psmetadatatest" `
778+ - TestSpecFileName " PsMetadataModuleTest.json" `
779+ - PsSwaggerPath (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" ) - TestRootPath $PSScriptRoot
780+
781+ # Import generated module
782+ Write-Verbose " Importing modules"
783+ Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" | Join-Path - ChildPath " PSSwagger.Common.Helpers" | `
784+ Join-Path - ChildPath " PSSwagger.Common.Helpers.psd1" ) - Force
785+ Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " .." | Join-Path - ChildPath " PSSwagger" | Join-Path - ChildPath " PSSwagger.Azure.Helpers" | `
786+ Join-Path - ChildPath " PSSwagger.Azure.Helpers.psd1" ) - Force
787+ Import-Module (Join-Path - Path $PSScriptRoot - ChildPath " Generated" | `
788+ Join-Path - ChildPath " Generated.PSMetadataTest.Module" )
789+ if ($global :PSSwaggerTest_EnableTracing -and $script :EnableTracer ) {
790+ $script :EnableTracer = $false
791+ Initialize-PSSwaggerDependencies - AcceptBootstrap
792+ Import-Module " $PSScriptRoot \PSSwaggerTestTracing.psm1"
793+ [Microsoft.Rest.ServiceClientTracing ]::AddTracingInterceptor((New-PSSwaggerTestClientTracing ))
794+ [Microsoft.Rest.ServiceClientTracing ]::IsEnabled = $true
795+ }
796+ }
797+
798+ Context " PSMetadataTest" {
799+ It " Override cmdlet name" {
800+ Get-Command Get-Cupcake - Module Generated.PSMetadataTest.Module - ErrorAction Ignore | should BeNullOrEmpty
801+ Get-Command List- Cupcakes - Module Generated.PSMetadataTest.Module | should not BeNullOrEmpty
802+ }
803+ }
722804}
0 commit comments