Skip to content

Commit

Permalink
Updated integration test for workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
johlju committed Sep 11, 2017
1 parent fa22634 commit 546f7a0
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions Tests/Integration/MSFT_xSQLServerSetup.Integration.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,18 @@ $TestEnvironment = Initialize-TestEnvironment `
#endregion

<#
Copies back the SQLPS module that was removed by AppVeyor.yml
(see issue #774).
SQLPS is removed because otherwise the common test will load
the SMO assembly and fail the unit tests (see issue #239)
$rootTempPath must be set to the same folder that was created
in the appveyor.yml file.
Workaround for issue #774. In the appveyor.yml file the folder
C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules
was renamed to
C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\Modules.old
here we rename back the folder to the correct name. Only the version need
for our tests are renamed.
#>
$rootTempPath = Join-Path -Path $env:TEMP -ChildPath 'SqlModuleTemp'
if (Test-Path -Path $rootTempPath)
{
$copyItemParameters = @{
Path = Join-Path -Path $rootTempPath -ChildPath '*'
Destination = 'C:\Program Files (x86)\Microsoft SQL Server\130\Tools\PowerShell\Modules'
Recurse = $true
Force = $true
}

Copy-Item @copyItemParameters
}
else
{
Write-Verbose -Message ('The folder ''{0}'' did not exist, ignoring copying SQLPS from temp path. Expecting it to be installed by SQL Server instead.' -f $rootTempPath) -Verbose
$sqlModulePath = Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft SQL Server\**\Tools\PowerShell\*.old'
$sqlModulePath | ForEach-Object -Process {
$newFolderName = (Split-Path -Path $_ -Leaf) -replace '\.old'
Write-Verbose ('Renaming ''{0}'' to ''..\{1}''' -f $_, $newFolderName) -Verbose
Rename-Item $_ -NewName $newFolderName -Force
}

$mockInstanceName = 'DSCSQL2016'
Expand Down

0 comments on commit 546f7a0

Please sign in to comment.