Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
751a6f4
Update mocks for RB2.0
dan-hughes Dec 30, 2025
cc21208
Update changelog
dan-hughes Dec 30, 2025
1594d47
Speedup test
dan-hughes Dec 30, 2025
3744510
Fix failing SqlDatabasePermission
dan-hughes Dec 30, 2025
0851325
Move setup code to before/after blocks
dan-hughes Dec 31, 2025
5f0154f
Merge branch 'main' into SQLAudit-Tests-for-resourcebase-2
dan-hughes Dec 31, 2025
5650966
Update SqlPermission tests for new base class
dan-hughes Dec 31, 2025
49f2301
Optimise QA tests
dan-hughes Dec 31, 2025
d3c79d8
Add strictmode
dan-hughes Dec 31, 2025
8644c6c
Update SqlPermission tests
dan-hughes Dec 31, 2025
7e959db
Update SqlDatabasePermission tests
dan-hughes Dec 31, 2025
c250332
Update DatabasePermission tests
dan-hughes Dec 31, 2025
73f94fd
Update ServerPermission tests
dan-hughes Dec 31, 2025
b257b69
Merge branch 'main' into SQLAudit-Tests-for-resourcebase-2
dan-hughes Dec 31, 2025
9fd2442
Fix SqlDatabasePermission tests
dan-hughes Dec 31, 2025
ab270aa
Fix ServerPermission
dan-hughes Dec 31, 2025
3e09b3e
Merge branch 'main' into SQLAudit-Tests-for-resourcebase-2
dan-hughes Jan 2, 2026
54a28bc
Update SqlRSSetup for latest RB
dan-hughes Jan 2, 2026
842221d
Move setup code to Before/After
dan-hughes Jan 3, 2026
7e6bb2d
Merge branch 'main' into SQLAudit-Tests-for-resourcebase-2
dan-hughes Jan 3, 2026
8a1d47c
Use PSCustomObject
dan-hughes Jan 3, 2026
b1511d4
Try optimize runtime
dan-hughes Jan 3, 2026
ad1a34e
Remove unnecessary assignment
dan-hughes Jan 3, 2026
af0035b
Update for RB2.0
dan-hughes Jan 3, 2026
46c936b
Update SqlAudit for RB2.0
dan-hughes Jan 3, 2026
53a5585
Fix Typo
dan-hughes Jan 3, 2026
b142ddd
Update changelog
dan-hughes Jan 3, 2026
77bdb5d
Create empty object
dan-hughes Jan 3, 2026
2e30bc9
Typo
dan-hughes Jan 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `SqlProtocol`
- Refactored to use the public command `Get-SqlDscServerProtocolName` instead
of the deprecated private function `Get-ProtocolNameProperties`
- `SqlAudit`
- Updated tests for ResourceBase 2.0.

### Fixed

Expand Down
19 changes: 7 additions & 12 deletions tests/QA/ScriptAnalyzer.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ BeforeDiscovery {

$moduleFiles = Get-ChildItem -Path $sourcePath -Recurse -Include @('*.psm1', '*.ps1')

$testCases = @()

foreach ($moduleFile in $moduleFiles)
$testCases = foreach ($moduleFile in $moduleFiles)
{
# Skipping Examples on Linux and macOS as they cannot be parsed.
if (($IsLinux -or $IsMacOs) -and $moduleFile.FullName -match 'Examples')
Expand All @@ -90,8 +88,8 @@ BeforeDiscovery {
$escapedRepositoryPath = [System.Text.RegularExpressions.RegEx]::Escape($repositoryPathNormalized)
$relativePath = $moduleFilePathNormalized -replace ($escapedRepositoryPath + '/')

$testCases += @{
ScriptPath = $moduleFile.FullName
@{
ScriptPath = $moduleFile.FullName
RelativePath = $relativePath
}
}
Expand All @@ -102,24 +100,21 @@ Describe 'Script Analyzer Rules' {
BeforeAll {
$repositoryPath = Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '../..')
$scriptAnalyzerSettingsPath = Join-Path -Path $repositoryPath -ChildPath '.vscode/analyzersettings.psd1'
}

It 'Should pass all PS Script Analyzer rules for file ''<RelativePath>''' -ForEach $testCases {
$pssaError = Invoke-ScriptAnalyzer -Path $ScriptPath -Settings $scriptAnalyzerSettingsPath

$parseErrorTypes = @(
'TypeNotFound'
'RequiresModuleInvalid'
)
}

It 'Should pass all PS Script Analyzer rules for file ''<RelativePath>''' -ForEach $testCases {
# Filter out reported parse errors that is unable to be resolved in source files
$pssaError = $pssaError |
$pssaError = Invoke-ScriptAnalyzer -Path $ScriptPath -Settings $scriptAnalyzerSettingsPath |
Where-Object -FilterScript {
$_.RuleName -notin $parseErrorTypes
}

$report = $pssaError |
Format-Table -AutoSize | Out-String -Width 200
$report = $pssaError | Format-Table -AutoSize | Out-String -Width 200

$pssaError | Should -HaveCount 0 -Because "all script analyzer rules should pass.`r`n`r`n $report`r`n"
}
Expand Down
18 changes: 6 additions & 12 deletions tests/QA/module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,18 @@ BeforeDiscovery {
$allModuleFunctions = & $mut { Get-Command -Module $args[0] -CommandType Function } $script:moduleName

# Build test cases.
$testCasesAllModuleFunction = @()

foreach ($function in $allModuleFunctions)
$testCasesAllModuleFunction = foreach ($function in $allModuleFunctions)
{
$testCasesAllModuleFunction += @{
@{
Name = $function.Name
}
}

$allPublicCommand = (Get-Command -Module $script:moduleName).Name

$testCasesPublicCommand = @()

foreach ($command in $allPublicCommand)
$testCasesPublicCommand = foreach ($command in $allPublicCommand)
{
$testCasesPublicCommand += @{
@{
Name = $command
}
}
Expand Down Expand Up @@ -218,9 +214,7 @@ Describe 'Comment-based help structure' -Tags 'helpQuality' {
# Split into lines to check each one
$helpLines = $helpBlock -split "`n"

$invalidDirectives = @()

foreach ($line in $helpLines)
$invalidDirectives = foreach ($line in $helpLines)
{
# Check if line starts with whitespace followed by a period and text
if ($line -match '^\s+\.([a-zA-Z]+)')
Expand All @@ -230,7 +224,7 @@ Describe 'Comment-based help structure' -Tags 'helpQuality' {
# Check if it's a valid directive
if ($directive -notin $validDirectives)
{
$invalidDirectives += $directive
$directive
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/TestHelpers/CommonTestHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ function Test-SetupArgument
$actualValues.Count | Should -Be $ExpectedArgument.Count `
-Because ('the expected arguments was: {0}' -f ($ExpectedArgument.Keys -join ','))

Write-Verbose -Message 'Verified actual setup argument values against expected setup argument values' -Verbose
Write-Verbose -Message 'Verified actual setup argument values against expected setup argument values'

foreach ($argumentKey in $ExpectedArgument.Keys)
{
Expand Down
Loading