Skip to content

Commit

Permalink
Refactoring Invoke-RestMethod to facilitate mocking. This closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
viananth authored and markcowl committed Dec 9, 2016
1 parent 26c7f09 commit 9008cdd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/AzureRM.BootStrapper/AzureRM.Bootstrapper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ else
$script:BootStrapRepo = $existingRepos[0].Name
}


function Get-ProfileCachePath
{
$ProfileCache = Join-Path -path $env:LOCALAPPDATA -childpath "Microsoft\AzurePowerShell\ProfileCache"
return $ProfileCache
}

# Make Rest-Call
function Get-RestResponse
{
$response = Invoke-RestMethod -ea SilentlyContinue -Uri $PSProfileMapEndpoint -ErrorVariable RestError -OutFile "$ProfileCache\ProfileMap.Json"
return $RestError
}

# Get-ProfileMap from Azure Endpoint
function Get-AzureProfileMap
Expand All @@ -30,7 +35,7 @@ function Get-AzureProfileMap
New-Item -ItemType Directory -Force -Path $ProfileCache | Out-Null
}

$response = Invoke-RestMethod -ea SilentlyContinue -Uri $PSProfileMapEndpoint -ErrorVariable RestError -OutFile "$ProfileCache\ProfileMap.Json"
$RestError = Get-RestResponse

if ($RestError)
{
Expand Down

0 comments on commit 9008cdd

Please sign in to comment.