Description
Extract the duplicated error handling logic from integration tests into a new public command that retrieves SQL Server setup bootstrap logs (Summary.txt).
Background
Currently, the error handling block that outputs Summary.txt content is duplicated across multiple integration tests. For example, in the Initialize-SqlDscRebuildDatabase integration test, this pattern appears three times (lines 95-120, 169-194, 225-250).
Proposal
Create a new public command Get-SqlDscSetupLog that:
- Retrieves the SQL Server setup bootstrap log (Summary.txt)
- Can be used interactively by users
- Accepts parameters to control behavior (e.g., path and filename) with sensible default values
- Can be reused across all integration tests needing this functionality
Example implementation structure:
function Get-SqlDscSetupLog
{
[CmdletBinding()]
param (
[Parameter()]
[System.String]
$Path = 'C:\Program Files\Microsoft SQL Server',
[Parameter()]
[System.String]
$FileName = 'Summary.txt'
)
$summaryFiles = Get-ChildItem -Path $Path -Filter $FileName -Recurse -ErrorAction 'SilentlyContinue' |
Where-Object { $_.FullName -match '\\Setup Bootstrap\\Log\\' } |
Sort-Object -Property 'LastWriteTime' -Descending |
Select-Object -First 1
if ($summaryFiles)
{
"==== SQL Server Setup Summary.txt (from $($summaryFiles.FullName)) ====="
Get-Content -Path $summaryFiles.FullName
"==== End of Summary.txt ====="
}
else
{
'No Summary.txt file found.'
}
}
Usage in integration tests:
catch
{
Write-Verbose -Message (Get-SqlDscSetupLog) -Verbose
throw $_
}
Tasks
References
Requested by: @johlju
Description
Extract the duplicated error handling logic from integration tests into a new public command that retrieves SQL Server setup bootstrap logs (Summary.txt).
Background
Currently, the error handling block that outputs Summary.txt content is duplicated across multiple integration tests. For example, in the Initialize-SqlDscRebuildDatabase integration test, this pattern appears three times (lines 95-120, 169-194, 225-250).
Proposal
Create a new public command
Get-SqlDscSetupLogthat:Example implementation structure:
Usage in integration tests:
Tasks
References
Requested by: @johlju