Skip to content

Commit 29aa5db

Browse files
committed
Fix unit tests
1 parent 5ee2aa8 commit 29aa5db

File tree

2 files changed

+373
-70
lines changed

2 files changed

+373
-70
lines changed

source/Classes/020.SqlRSSetup.ps1

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,38 +218,57 @@ class SqlRSSetup : ResourceBase
218218

219219
$actionStateResult = $baseTestResult
220220

221-
if (-not $baseTestResult -and $this.Action -in @('Repair', 'Uninstall'))
221+
if ($this.Action -eq 'Repair' -and -not $baseTestResult)
222222
{
223-
<#
224-
If the instance is not installed and the action is Repair or Uninstall
225-
then set the $actionStateResult to $true. This indicates that it is
226-
not possible to perform a repair or there is nothing to uninstall.
227-
#>
223+
# Instance is not installed, so it is not possible to perform a repair.
228224
$actionStateResult = $true
229225
}
230226

227+
if ($this.Action -in @('Uninstall', 'Repair'))
228+
{
229+
if ($baseTestResult)
230+
{
231+
# Instance is installed, it should be uninstalled or repaired.
232+
$actionStateResult = $false
233+
}
234+
else
235+
{
236+
<#
237+
Instance is not installed, or it is not possible to perform a
238+
repair since the instance is uninstalled.
239+
#>
240+
$actionStateResult = $true
241+
}
242+
}
243+
231244
$productVersionInDesiredState = $true
232245

233-
# The product version is evaluated if VersionUpgrade is set to $true.
234-
if ($this.Action -eq 'Install' -and $this.VersionUpgrade)
246+
<#
247+
The product version is evaluated if action is Install, instance is
248+
installed and VersionUpgrade is set to $true.
249+
#>
250+
if ($this.Action -eq 'Install' -and $baseTestResult -and $this.VersionUpgrade)
235251
{
236252
$fileVersion = Get-FileProductVersion -Path $this.MediaPath -ErrorAction 'Stop'
237253

238254
if ($fileVersion)
239255
{
240256
$getTargetResourceResult = $this.GetCurrentState(@{
241-
InstanceName = $this.InstanceName
242-
})
257+
InstanceName = $this.InstanceName
258+
})
243259

244260
$installedVersion = [System.Version] $getTargetResourceResult.ProductVersion
245261

246262
if ($installedVersion -lt $fileVersion)
247263
{
248264
$productVersionInDesiredState = $false
249265

250-
Write-Verbose -Message $this.localizedData.NotDesiredProductVersion -f @(
251-
$fileVersion.ToString(),
252-
$this.InstanceName, $installedVersion.ToString()
266+
Write-Verbose -Message (
267+
$this.localizedData.NotDesiredProductVersion -f @(
268+
$fileVersion.ToString(),
269+
$this.InstanceName,
270+
$installedVersion.ToString()
271+
)
253272
)
254273
}
255274
}

0 commit comments

Comments
 (0)