PowerShell / DscConfiguration.Tests

Test automation scripts for evaluating the quality of DSC Configurations using Azure virtual machines and Azure Automation DSC.
MIT License
5 stars 11 forks source link

Unable to run locally without setting environment variables #28

Open johlju opened 7 years ago

johlju commented 7 years ago

To be able to run this locally the environment variables need to be set to mimic the behavior of AppVeyor.

I ended up creating a script Start-Build.ps1 in the root folder that sets the variables before running Invoke-Build. This is not an optimal idea since this script generate a varning in the unit test that Invoke-Build is an alias, and should be change to point to the full script path 'C:\Program Files\WindowsPowerShell\Modules\InvokeBuild\3.6.4\Invoke-Build.ps1'. Since the version can change, it's not possible to change to the full path.

$env:TenantID = '<guid>'
$env:SubscriptionID = '<guid>'
$env:ApplicationID = '<guid>'
$env:ApplicationPassword = '<key/password>'
$env:Location = 'westeurope' # Used by @PlagueHO's branch (PR #21).

$env:BuildFolder = $PSScriptRoot
$env:ProjectName = Split-Path -Path $PSScriptRoot -Leaf
$env:ProjectID = New-Guid # This is used to create a folder in $env:TEMP.
$env:BuildID = 1001 # Any number

Invoke-Build -File .\DscConfiguration.Tests\.build.ps1 -Summary
johlju commented 7 years ago

Please note that I also added that file to .gitignore so it doesn't get pushed to the repository.

johlju commented 7 years ago

It's not possible to use this to override the warning mentioned above because then the tests fail on an unallowed override was used. 😄

# Suppressing this rule because Invoke-Build is an alias
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingCmdletAliases', '')]
param()