Skip to content

Commit c23444d

Browse files
feat: enhance test scripts with detailed documentation and improve directory search function
1 parent 9d59f8a commit c23444d

File tree

3 files changed

+43
-6
lines changed

3 files changed

+43
-6
lines changed

.github/linters/.powershell-psscriptanalyzer.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
}
5151
}
5252
ExcludeRules = @(
53+
'PSAvoidUsingWriteHost', # Write-Host is acceptable in GitHub Actions runners
5354
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
5455
'PSUseToExportFieldsInManifest'
5556
)

scripts/main.ps1

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,36 @@ process {
249249
return $testFiles
250250
}
251251

252-
function Find-TestDirectories {
253-
param ([string]$Path)
252+
<#
253+
.SYNOPSIS
254+
Recursively finds all test directories.
255+
256+
.DESCRIPTION
257+
Recursively searches for all subdirectories within the specified path.
258+
259+
.OUTPUTS
260+
System.String[]
261+
Returns an array of directory paths.
262+
#>
263+
function Find-TestDirectory {
264+
[CmdletBinding()]
265+
param(
266+
#The root path to search for test directories.
267+
[string]$Path
268+
)
254269

255270
$directories = @()
256271
$childDirs = Get-ChildItem -Path $Path -Directory
257272

258273
foreach ($dir in $childDirs) {
259274
$directories += $dir.FullName
260-
$directories += Find-TestDirectories -Path $dir.FullName
275+
$directories += Find-TestDirectory -Path $dir.FullName
261276
}
262277

263278
return $directories
264279
}
265280

266-
$allTestFolders = @($testsPath) + (Find-TestDirectories -Path $testsPath)
281+
$allTestFolders = @($testsPath) + (Find-TestDirectory -Path $testsPath)
267282

268283
foreach ($folder in $allTestFolders) {
269284
$testItems = Get-TestItemsFromFolder -FolderPath $folder

tests/Validate-Settings.ps1

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,30 @@ Write-Host "`nComparing with reference settings..."
5151
$referencePath = Join-Path $PSScriptRoot 'Settings.json'
5252
$expectedSettings = Get-Content $referencePath -Raw | ConvertFrom-Json
5353

54-
# Function to compare object structures
54+
<#
55+
.SYNOPSIS
56+
Compares the structure of two objects.
57+
58+
.DESCRIPTION
59+
Recursively compares the structure of an actual object against an expected object,
60+
validating that all expected properties exist in the actual object.
61+
62+
.OUTPUTS
63+
System.String[]
64+
Returns an array of error messages for any structural mismatches.
65+
#>
5566
function Test-ObjectStructure {
56-
param($Actual, $Expected, $Path = 'Root')
67+
[CmdletBinding()]
68+
param(
69+
# The actual object to validate.
70+
$Actual,
71+
72+
# The expected object structure to validate against.
73+
$Expected,
74+
75+
# The current path in the object hierarchy (used for error reporting).
76+
$Path = 'Root'
77+
)
5778

5879
$errors = @()
5980

0 commit comments

Comments
 (0)