Skip to content

Commit 8aca1f5

Browse files
committed
Refactor integration tests to remove unnecessary script blocks
- Simplified the structure of the integration tests by removing redundant script blocks that encapsulated the configuration parameters and DSC configuration calls. - Ensured that the tests still compile and apply the MOF without throwing exceptions. - Updated the tests across multiple files: DSC_SqlRS_Default, DSC_SqlServiceAccount, DSC_SqlSetup, DSC_SqlWindowsFirewall to maintain consistency and improve readability.
1 parent 2ec83b4 commit 8aca1f5

7 files changed

+734
-882
lines changed

tests/Integration/Resources/DSC_SqlAlwaysOnService.Integration.Tests.ps1

Lines changed: 66 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,24 @@ Describe "$($script:dscResourceName)_Integration" -Tag 'Skip' {
8787
}
8888

8989
It 'Should compile and apply the MOF without throwing' {
90-
{
91-
$configurationParameters = @{
92-
OutputPath = $TestDrive
93-
# The variable $ConfigurationData was dot-sourced above.
94-
ConfigurationData = $ConfigurationData
95-
}
96-
97-
$null = & $configurationName @configurationParameters
98-
99-
$startDscConfigurationParameters = @{
100-
Path = $TestDrive
101-
ComputerName = 'localhost'
102-
Wait = $true
103-
Verbose = $true
104-
Force = $true
105-
ErrorAction = 'Stop'
106-
}
107-
108-
Start-DscConfiguration @startDscConfigurationParameters
109-
} | Should -Not -Throw
90+
$configurationParameters = @{
91+
OutputPath = $TestDrive
92+
# The variable $ConfigurationData was dot-sourced above.
93+
ConfigurationData = $ConfigurationData
94+
}
95+
96+
$null = & $configurationName @configurationParameters
97+
98+
$startDscConfigurationParameters = @{
99+
Path = $TestDrive
100+
ComputerName = 'localhost'
101+
Wait = $true
102+
Verbose = $true
103+
Force = $true
104+
ErrorAction = 'Stop'
105+
}
106+
107+
$null = Start-DscConfiguration @startDscConfigurationParameters
110108
}
111109
}
112110

@@ -122,26 +120,24 @@ Describe "$($script:dscResourceName)_Integration" -Tag 'Skip' {
122120
}
123121

124122
It 'Should compile and apply the MOF without throwing' {
125-
{
126-
$configurationParameters = @{
127-
OutputPath = $TestDrive
128-
# The variable $ConfigurationData was dot-sourced above.
129-
ConfigurationData = $ConfigurationData
130-
}
123+
$configurationParameters = @{
124+
OutputPath = $TestDrive
125+
# The variable $ConfigurationData was dot-sourced above.
126+
ConfigurationData = $ConfigurationData
127+
}
131128

132-
$null = & $configurationName @configurationParameters
129+
$null = & $configurationName @configurationParameters
133130

134-
$startDscConfigurationParameters = @{
135-
Path = $TestDrive
136-
ComputerName = 'localhost'
137-
Wait = $true
138-
Verbose = $true
139-
Force = $true
140-
ErrorAction = 'Stop'
141-
}
131+
$startDscConfigurationParameters = @{
132+
Path = $TestDrive
133+
ComputerName = 'localhost'
134+
Wait = $true
135+
Verbose = $true
136+
Force = $true
137+
ErrorAction = 'Stop'
138+
}
142139

143-
Start-DscConfiguration @startDscConfigurationParameters
144-
} | Should -Not -Throw
140+
$null = Start-DscConfiguration @startDscConfigurationParameters
145141
}
146142

147143
It 'Should be able to call Get-DscConfiguration without throwing' {
@@ -174,26 +170,24 @@ Describe "$($script:dscResourceName)_Integration" -Tag 'Skip' {
174170
}
175171

176172
It 'Should compile and apply the MOF without throwing' {
177-
{
178-
$configurationParameters = @{
179-
OutputPath = $TestDrive
180-
# The variable $ConfigurationData was dot-sourced above.
181-
ConfigurationData = $ConfigurationData
182-
}
173+
$configurationParameters = @{
174+
OutputPath = $TestDrive
175+
# The variable $ConfigurationData was dot-sourced above.
176+
ConfigurationData = $ConfigurationData
177+
}
183178

184-
$null = & $configurationName @configurationParameters
179+
$null = & $configurationName @configurationParameters
185180

186-
$startDscConfigurationParameters = @{
187-
Path = $TestDrive
188-
ComputerName = 'localhost'
189-
Wait = $true
190-
Verbose = $true
191-
Force = $true
192-
ErrorAction = 'Stop'
193-
}
181+
$startDscConfigurationParameters = @{
182+
Path = $TestDrive
183+
ComputerName = 'localhost'
184+
Wait = $true
185+
Verbose = $true
186+
Force = $true
187+
ErrorAction = 'Stop'
188+
}
194189

195-
Start-DscConfiguration @startDscConfigurationParameters
196-
} | Should -Not -Throw
190+
$null = Start-DscConfiguration @startDscConfigurationParameters
197191
}
198192

199193
It 'Should be able to call Get-DscConfiguration without throwing' {
@@ -226,26 +220,24 @@ Describe "$($script:dscResourceName)_Integration" -Tag 'Skip' {
226220
}
227221

228222
It 'Should compile and apply the MOF without throwing' {
229-
{
230-
$configurationParameters = @{
231-
OutputPath = $TestDrive
232-
# The variable $ConfigurationData was dot-sourced above.
233-
ConfigurationData = $ConfigurationData
234-
}
235-
236-
$null = & $configurationName @configurationParameters
237-
238-
$startDscConfigurationParameters = @{
239-
Path = $TestDrive
240-
ComputerName = 'localhost'
241-
Wait = $true
242-
Verbose = $true
243-
Force = $true
244-
ErrorAction = 'Stop'
245-
}
246-
247-
Start-DscConfiguration @startDscConfigurationParameters
248-
} | Should -Not -Throw
223+
$configurationParameters = @{
224+
OutputPath = $TestDrive
225+
# The variable $ConfigurationData was dot-sourced above.
226+
ConfigurationData = $ConfigurationData
227+
}
228+
229+
$null = & $configurationName @configurationParameters
230+
231+
$startDscConfigurationParameters = @{
232+
Path = $TestDrive
233+
ComputerName = 'localhost'
234+
Wait = $true
235+
Verbose = $true
236+
Force = $true
237+
ErrorAction = 'Stop'
238+
}
239+
240+
$null = Start-DscConfiguration @startDscConfigurationParameters
249241
}
250242
}
251243
}

0 commit comments

Comments
 (0)