@@ -42,25 +42,38 @@ BeforeAll {
4242#>
4343Describe " $ ( $script :dscResourceFriendlyName ) _Integration" - Tag @ (' Integration_SQL2017' , ' Integration_SQL2019' , ' Integration_SQL2022' , ' Integration_PowerBI' ) {
4444 Context ' When getting the current state of the resource' {
45+ BeforeAll {
46+ # Get temporary folder for the test and make sure it exists, if not create it
47+ $tempFolder = Get-TemporaryFolder
48+ Write-Verbose - Message " Temporary folder is $tempFolder "
49+ if (-not (Test-Path - Path $tempFolder ))
50+ {
51+ Write-Verbose - Message " Temporary folder did not exist, creating temporary folder $tempFolder "
52+ New-Item - Path $tempFolder - ItemType Directory - Force | Out-Null
53+ }
54+ }
55+
4556 It ' Should return the expected current state' {
4657 # Media file has already been saved to (Get-TemporaryFolder)\PowerBIReportServer.exe
4758 $desiredParameters = @ {
4859 InstanceName = ' PBIRS'
4960 AcceptLicensingTerms = $true
5061 Action = ' Install'
51- MediaPath = Join-Path - Path ( Get-TemporaryFolder ) - ChildPath ' PowerBIReportServer.exe'
62+ MediaPath = Join-Path - Path $tempFolder - ChildPath ' PowerBIReportServer.exe'
5263 InstallFolder = Join-Path - Path $env: ProgramFiles - ChildPath ' Microsoft Power BI Report Server'
5364 Edition = ' Developer'
5465 SuppressRestart = $true
55- LogPath = Join-Path - Path ( Get-TemporaryFolder ) - ChildPath ' PBIRS.log'
66+ LogPath = Join-Path - Path $tempFolder - ChildPath ' PBIRS.log'
5667 VersionUpgrade = $true
5768 }
5869
5970 dsc -- trace-level trace resource get -- resource SqlServerDsc/ SqlRSSetup -- output- format pretty- json -- input ($desiredParameters | ConvertTo-Json - Compress)
6071
61- if ($LASTEXITCODE -ne 0 )
72+ $dscExitCode = $LASTEXITCODE # cSpell: ignore LASTEXITCODE
73+
74+ if ($dscExitCode -ne 0 )
6275 {
63- throw ' Failed to get the current state of the resource. '
76+ throw ( ' DSC executable failed with exit code {0}. ' -f $dscExitCode )
6477 }
6578 }
6679 }
0 commit comments