-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathRepair-SqlDscPowerBIReportServer.Integration.Tests.ps1
More file actions
74 lines (60 loc) · 3 KB
/
Repair-SqlDscPowerBIReportServer.Integration.Tests.ps1
File metadata and controls
74 lines (60 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '', Justification = 'Suppressing this rule because Script Analyzer does not understand Pester syntax.')]
param ()
BeforeDiscovery {
try
{
if (-not (Get-Module -Name 'DscResource.Test'))
{
# Assumes dependencies have been resolved, so if this module is not available, run 'noop' task.
if (-not (Get-Module -Name 'DscResource.Test' -ListAvailable))
{
# Redirect all streams to $null, except the error stream (stream 2)
& "$PSScriptRoot/../../../build.ps1" -Tasks 'noop' 3>&1 4>&1 5>&1 6>&1 > $null
}
# If the dependencies have not been resolved, this will throw an error.
Import-Module -Name 'DscResource.Test' -Force -ErrorAction 'Stop'
}
}
catch [System.IO.FileNotFoundException]
{
throw 'DscResource.Test module dependency not found. Please run ".\build.ps1 -ResolveDependency -Tasks noop" first.'
}
}
BeforeAll {
$script:moduleName = 'SqlServerDsc'
Import-Module -Name $script:moduleName -Force -ErrorAction 'Stop'
}
Describe 'Repair-SqlDscPowerBIReportServer' -Tag @('Integration_PowerBI') {
BeforeAll {
Write-Verbose -Message ('Running integration test as user ''{0}''.' -f $env:UserName) -Verbose
# Starting the Power BI Report Server service prior to running tests.
Start-Service -Name 'PowerBIReportServer' -Verbose -ErrorAction 'Stop'
$script:temporaryFolder = Get-TemporaryFolder
# Get the path to the Power BI Report Server executable
$powerBIReportServerExecutable = Join-Path -Path $script:temporaryFolder -ChildPath 'PowerBIReportServer.exe'
}
It 'Should have the BI Report Server service running' {
$getServiceResult = Get-Service -Name 'PowerBIReportServer' -ErrorAction 'Stop'
$getServiceResult.Status | Should -Be 'Running'
}
Context 'When repairing BI Report Server' {
It 'Should run the command without throwing' {
# Set splatting parameters for Repair-SqlDscPowerBIReportServer
$repairSqlDscBIReportServerParameters = @{
AcceptLicensingTerms = $true
MediaPath = $powerBIReportServerExecutable
LogPath = Join-Path -Path $script:temporaryFolder -ChildPath 'SSRS_Repair.log'
SuppressRestart = $true
Verbose = $true
ErrorAction = 'Stop'
Force = $true
}
$null = Repair-SqlDscPowerBIReportServer @repairSqlDscBIReportServerParameters
}
It 'Should still have a Power BI Report Server service running after repair' {
$getServiceResult = Get-Service -Name 'PowerBIReportServer' -ErrorAction 'Stop'
$getServiceResult | Should -Not -BeNullOrEmpty
$getServiceResult.Status | Should -Be 'Running'
}
}
}