Skip to content

Commit

Permalink
Not sure where NullReference exception on AppVeyor is coming from
Browse files Browse the repository at this point in the history
  • Loading branch information
nyanhp committed Nov 22, 2018
1 parent 9d1ea64 commit 85a2ccb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{
Write-Verbose -Message "$($moduleName) Missing, installing Module"
Install-Module -Name $moduleName -Force -AllowClobber
Import-Module -Name $moduleName -Force -RequiredVersion $version
Import-Module -Name $moduleName -Force
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions Tests/Integration/Get-LabConfigurationItem.tests.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Use settings.psd1 from build to check all settings
$configurationPath = $(Resolve-Path -Path "$PSScriptRoot\..\..\AutomatedLab\settings.psd1" -ErrorAction Stop).Path
$rootpath = $PSScriptRoot
$configurationPath = $(Resolve-Path -Path "$rootpath\..\..\AutomatedLab\settings.psd1" -ErrorAction Stop).Path

if (-not (Get-Module -List Newtonsoft.Json)) {Install-Module -Name Newtonsoft.Json -Force -SkipPublisherCheck -AllowClobber}
if (-not (Get-Module -List powershell-yaml)) {Install-Module -Name powershell-yaml -Force -SkipPublisherCheck -AllowClobber}
if (-not (Get-Module -List Datum)) {Install-Module -Name Datum -Force -SkipPublisherCheck -AllowClobber}

Import-Module -Name Newtonsoft.Json,powershell-yaml
Import-Module -Name Datum,"$PSScriptRoot\..\..\AutomatedLab.Common\AutomatedLab.Common" -Force
Import-Module -Name Datum,"$rootpath\..\..\AutomatedLab.Common\AutomatedLab.Common\AutomatedLab.Common.psd1" -Force -Verbose
[System.Environment]::SetEnvironmentVariable('AUTOMATEDLAB_TELEMETRY_OPTOUT',0, 'Machine')
$env:AUTOMATEDLAB_TELEMETRY_OPTOUT = 0

Expand All @@ -22,12 +23,14 @@ $reqdModules = @(
)
foreach ($mod in $reqdModules)
{
Import-Module -Name "$PSScriptRoot\..\..\$mod" -Force
Write-Host "Importing $(Resolve-Path -Path "$rootpath\..\..\$mod\$mod.psd1")"
Import-Module -Name "$rootpath\..\..\$mod\$mod.psd1" -Force
}

Write-Host "Testing with Pester $($(Get-Module -Name Pester).Version)"

Describe 'Get-LabConfigurationItem' {
$functionCalls = (Get-ChildItem -Path "$PSScriptRoot\..\.." -Recurse -Filter *.ps*1 | select-string -Pattern 'Get-LabConfigurationItem -Name \w+').Matches.Value | Sort-Object -Unique
$functionCalls = (Get-ChildItem -Path "$rootpath\..\.." -Recurse -Filter *.ps*1 | select-string -Pattern 'Get-LabConfigurationItem -Name \w+').Matches.Value | Sort-Object -Unique

It 'Should contain all settings' {
Get-LabConfigurationItem -GlobalPath $configurationPath | Should -Not -Be $null
Expand Down
3 changes: 3 additions & 0 deletions psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Task Test -Depends Init {
$lines
"`n`tSTATUS: Testing with PowerShell $PSVersion"

# Ensure recent Pester version is actually used
Import-Module -Name Pester -MinimumVersion 4.0.0 -Force

# Gather test results. Store them in a variable and file
$TestResults = Invoke-Pester -Path $ProjectRoot\Tests -PassThru -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile"

Expand Down

0 comments on commit 85a2ccb

Please sign in to comment.