Azure / autorest.powershell

AutoRest PowerShell Generator
MIT License
112 stars 83 forks source link

"There is no Runspace available" issue #400

Closed MiYanni closed 5 years ago

MiYanni commented 5 years ago

This happens when running tests. Happens when using both HttpPipelineAppend and HttpPipelinePrepend.

PS C:\Code\azps-generation\src\Dns> .\test-module.ps1 -Record
Creating isolated process...
Executing all tests in 'C:\Code\azps-generation\src\Dns\test'

Executing script C:\Code\azps-generation\src\Dns\test\Get-AzDnsTestMe.Tests.ps1

  Describing Get-AzDnsTestMe
    [-] Scenario 577ms
      Expected no exception to be thrown, but an exception "There is no Runspace available to run scripts in this thread. You can provide one in the DefaultRunspace property of the System.Management.Automation.Runspaces.Runspace type. The script block you attempted to invoke was: param($request,...nse)
          }
        }
      " was thrown from C:\Code\azps-generation\src\Dns\test\Get-AzDnsTestMe.Tests.ps1:9 char:11
          +         { New-AzDnsZone -Name www.miyanni.zone -ResourceGroupName miy ...
          +           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
      9:         { New-AzDnsZone -Name www.miyanni.zone -ResourceGroupName miyanni-test -Location 'global' } | Should -Not -Throw
      at <ScriptBlock>, C:\Code\azps-generation\src\Dns\test\Get-AzDnsTestMe.Tests.ps1: line 9
Tests completed in 1.06s
Tests Passed: 0, Failed: 1, Skipped: 0, Pending: 0, Inconclusive: 0
-------------Done-------------
fearthecowboy commented 5 years ago

I've updated the generator to wrap the steps with a bit of code that will create a runspace -- can you test it and see if it works?

MiYanni commented 5 years ago

image

Same error.

MiYanni commented 5 years ago

Fixed.