Skip to content
Merged
Changes from 1 commit
Commits
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
Next Next commit
Test if verbose switch is enabled in functions
  • Loading branch information
MariusStorhaug committed Apr 14, 2024
commit 2d6091c98343e490d3455288e9fa0347b40f40e8
11 changes: 11 additions & 0 deletions scripts/tests/PSModule/SourceCode.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ Describe 'PSModule - SourceCode tests' {

# It 'All script files have tests' {} # Look for the folder name in tests called the same as section/folder name of functions

It 'Should not contain a -Verbose switch which is not directly disabled using :$false' {
$issues = @('')
$scriptFiles | ForEach-Object {
Select-String -Path $_.FullName -Pattern '-Verbose(?!\:\$false)' -AllMatches | ForEach-Object {
$issues += " - $($_.Path):L$($_.LineNumber)"
}

}
$issues -join [Environment]::NewLine |
Should -BeNullOrEmpty -Because 'the script should not contain a -Verbose switch which is not directly disabled using :$false'
}
}

Context 'Function/filter design' {
Expand Down