test/utils.ps1
function RandomString([bool]$allChars, [int32]$len) { if ($allChars) { return -join ((33..126) | Get-Random -Count $len | % {[char]$_}) } else { return -join ((48..57) + (97..122) | Get-Random -Count $len | % {[char]$_}) } } $env = @{} function setupEnv() { # Preload subscriptionId and tenant from context, which will be used in test # as default. You could change them if needed. $env.SubscriptionId = (Get-AzContext).Subscription.Id $env.Tenant = (Get-AzContext).Tenant.Id # For any resources you created for test, you should add it to $env here. $envFile = 'env.json' if ($TestMode -eq 'live') { $envFile = 'localEnv.json' } set-content -Path (Join-Path $PSScriptRoot $envFile) -Value (ConvertTo-Json $env) } function cleanupEnv() { # Clean resources you create for testing } |