Skip to content

Commit 541ce0a

Browse files
committed
Add MediaPath parameter to Assert-SetupActionProperties tests for improved validation
1 parent 1062189 commit 541ce0a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

tests/Unit/Private/Assert-SetupActionProperties.Tests.ps1

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ AfterAll {
4747
}
4848

4949
Describe 'Assert-SetupActionProperties' -Tag 'Private' {
50+
BeforeAll {
51+
Mock -CommandName Get-FileVersion -MockWith {
52+
return [PSCustomObject] @{
53+
ProductVersion = '16.0.1000.6'
54+
}
55+
}
56+
}
57+
5058
Context 'When all properties are valid for setup action ''<MockSetupAction>''' -ForEach @(
5159
@{
5260
MockSetupAction = 'Install'
@@ -100,6 +108,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
100108
It 'Should not throw an exception' {
101109
InModuleScope -Parameters $_ -ScriptBlock {
102110
$null = Assert-SetupActionProperties -Property @{
111+
MediaPath = $TestDrive
103112
ValidProperty = 'Value'
104113
} -SetupAction $MockSetupAction -ErrorAction 'Stop'
105114
}
@@ -118,6 +127,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
118127
InModuleScope -Parameters $_ -ScriptBlock {
119128
{
120129
Assert-SetupActionProperties -Property @{
130+
MediaPath = $TestDrive
121131
$MockParameterName = 'Value'
122132
} -SetupAction 'NotUsed'
123133
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -162,6 +172,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
162172
It 'Should throw the correct error' {
163173
InModuleScope -Parameters $_ -ScriptBlock {
164174
{
175+
$MockParameters.MediaPath = $TestDrive
165176
$MockParameters.Role = 'SPI_AS_NewFarm'
166177

167178
Assert-SetupActionProperties -Property $MockParameters -SetupAction 'NotUsed'
@@ -175,6 +186,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
175186
InModuleScope -ScriptBlock {
176187
{
177188
Assert-SetupActionProperties -Property @{
189+
MediaPath = $TestDrive
178190
SecurityMode = 'SQL'
179191
} -SetupAction 'NotUsed'
180192
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -188,6 +200,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
188200
MockFileStreamLevel = $_
189201
} -ScriptBlock {
190202
$null = Assert-SetupActionProperties -Property @{
203+
MediaPath = $TestDrive
191204
FileStreamLevel = $MockFileStreamLevel
192205
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
193206
}
@@ -201,6 +214,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
201214
} -ScriptBlock {
202215
{
203216
Assert-SetupActionProperties -Property @{
217+
MediaPath = $TestDrive
204218
FileStreamLevel = $MockFileStreamLevel
205219
} -SetupAction 'NotUsed'
206220
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -238,6 +252,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
238252
InModuleScope -Parameters $_ -ScriptBlock {
239253
{
240254
Assert-SetupActionProperties -Property @{
255+
MediaPath = $TestDrive
241256
$MockParameterName = 'AccountName'
242257
} -SetupAction 'NotUsed'
243258
} | Should -Throw -ErrorId 'ARCP0001,Assert-RequiredCommandParameter' # cSpell: disable-line
@@ -274,7 +289,8 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
274289
It 'Should not throw an exception' {
275290
InModuleScope -Parameters $_ -ScriptBlock {
276291
$null = Assert-SetupActionProperties -Property @{
277-
$MockParameterName = 'AccountName'
292+
MediaPath = $TestDrive
293+
$MockParameterName = 'AccountName'
278294
($MockParameterName -replace 'Account', 'Password') = 'Password'
279295
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
280296
}
@@ -316,6 +332,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
316332
It 'Should not throw an exception' {
317333
InModuleScope -Parameters $_ -ScriptBlock {
318334
$null = Assert-SetupActionProperties -Property @{
335+
MediaPath = $TestDrive
319336
$MockParameterName = 'myMSA$'
320337
} -SetupAction 'NotUsed' -ErrorAction 'Stop'
321338
}
@@ -553,6 +570,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
553570
InModuleScope -Parameters $_ -ScriptBlock {
554571
{
555572
Assert-SetupActionProperties -Property @{
573+
MediaPath = $TestDrive
556574
ASServerMode = 'PowerPivot'
557575
} -SetupAction $MockSetupAction
558576
} | Should -Throw -ErrorId 'ASAP0001,Assert-SetupActionProperties' # cSpell: disable-line
@@ -569,6 +587,7 @@ Describe 'Assert-SetupActionProperties' -Tag 'Private' {
569587
InModuleScope -Parameters $_ -ScriptBlock {
570588
{
571589
Assert-SetupActionProperties -Property @{
590+
MediaPath = $TestDrive
572591
RsInstallMode = 'DefaultNativeMode'
573592
} -SetupAction $MockSetupAction
574593
} | Should -Throw -ErrorId 'ASAP0002,Assert-SetupActionProperties' # cSpell: disable-line

0 commit comments

Comments
 (0)