Skip to content

Commit f5fd7d6

Browse files
authored
Fixing issue in Initialize-TestEnvironment (#98)
- Fix issue where the use of ScriptsToProcess causes the Initialize-TestEnvironment function to fail (issue #97).
1 parent 75778b9 commit f5fd7d6

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fix issue where the use of ScriptsToProcess causes the Initialize-TestEnvironment
13+
function to fail ([issue #97](https://github.com/dsccommunity/DscResource.Test/issues/97)).
14+
1015
## [0.14.2] - 2021-01-05
1116

1217
### Fixed

source/Public/Initialize-TestEnvironment.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,18 @@ function Initialize-TestEnvironment
105105
$ResourceType = 'Mof',
106106

107107
[Parameter()]
108-
[ValidateSet('AllSigned', 'Bypass','RemoteSigned','Unrestricted')]
108+
[ValidateSet('AllSigned', 'Bypass', 'RemoteSigned', 'Unrestricted')]
109109
[String]
110110
$ProcessExecutionPolicy,
111111

112112
[Parameter()]
113-
[ValidateSet('AllSigned', 'Bypass','RemoteSigned','Unrestricted')]
113+
[ValidateSet('AllSigned', 'Bypass', 'RemoteSigned', 'Unrestricted')]
114114
[String]
115115
$MachineExecutionPolicy
116116
)
117117

118118
Write-Verbose -Message "Initializing test environment for $TestType testing of $DscResourceName in module $Module"
119-
$ModuleUnderTest = Import-Module $Module -PassThru -ErrorAction Stop
119+
$ModuleUnderTest = (Import-Module $Module -PassThru -ErrorAction Stop) | Where-Object -FilterScript { $_.Name -eq $Module } # The Where-Object filter is added to fix issue #97
120120
$moduleRootFilePath = $ModuleUnderTest.ModuleBase
121121
$moduleManifestFilePath = Join-Path -Path $moduleRootFilePath -ChildPath "$($ModuleUnderTest.Name).psd1"
122122

@@ -130,7 +130,7 @@ function Initialize-TestEnvironment
130130
}
131131

132132
# Import the module to test
133-
if ($TestType -in ('Unit','All'))
133+
if ($TestType -in ('Unit', 'All'))
134134
{
135135
switch ($ResourceType)
136136
{
@@ -206,7 +206,7 @@ function Initialize-TestEnvironment
206206

207207
Set-PSModulePath -Path $newPSModulePath
208208

209-
if ($TestType -in ('Integration','All'))
209+
if ($TestType -in ('Integration', 'All'))
210210
{
211211
<#
212212
Making sure setting up the LCM & Machine Path makes sense...

0 commit comments

Comments
 (0)