Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 [Patch]: Add test where enabling -Verbose in a function is not allowed #53

Merged
merged 8 commits into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions scripts/tests/PSModule/SourceCode.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ 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 '-Verbose' unless it is disabled using ':`$false' qualifier after it" {
$issues = @('')
$scriptFiles | ForEach-Object {
Select-String -Path $_.FullName -Pattern '\s(-Verbose(?::\$true)?)\b(?!:\$false)' -AllMatches | ForEach-Object {
$issues += " - $($_.Path):L$($_.LineNumber)"
}
}
$issues -join [Environment]::NewLine |
Should -BeNullOrEmpty -Because "the script should not contain '-Verbose' unless it is disabled using ':`$false' qualifier after it."
}
}

Context 'Function/filter design' {
Expand Down
6 changes: 3 additions & 3 deletions tests/src/finally.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '------------------------------' -Verbose
Write-Verbose '--- THIS IS A LAST LOADER ---' -Verbose
Write-Verbose '------------------------------' -Verbose
Write-Verbose '------------------------------'
Write-Verbose '--- THIS IS A LAST LOADER ---'
Write-Verbose '------------------------------'
6 changes: 3 additions & 3 deletions tests/src/init/initializer.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '-------------------------------' -Verbose
Write-Verbose '--- THIS IS AN INITIALIZER ---' -Verbose
Write-Verbose '-------------------------------' -Verbose
Write-Verbose '-------------------------------'
Write-Verbose '--- THIS IS AN INITIALIZER ---'
Write-Verbose '-------------------------------'
6 changes: 3 additions & 3 deletions tests/src/scripts/loader.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '-------------------------' -Verbose
Write-Verbose '--- THIS IS A LOADER ---' -Verbose
Write-Verbose '-------------------------' -Verbose
Write-Verbose '-------------------------'
Write-Verbose '--- THIS IS A LOADER ---'
Write-Verbose '-------------------------'
6 changes: 3 additions & 3 deletions tests/srcWithManifest/finally.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '------------------------------' -Verbose
Write-Verbose '--- THIS IS A LAST LOADER ---' -Verbose
Write-Verbose '------------------------------' -Verbose
Write-Verbose '------------------------------'
Write-Verbose '--- THIS IS A LAST LOADER ---'
Write-Verbose '------------------------------'
6 changes: 3 additions & 3 deletions tests/srcWithManifest/init/initializer.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '-------------------------------' -Verbose
Write-Verbose '--- THIS IS AN INITIALIZER ---' -Verbose
Write-Verbose '-------------------------------' -Verbose
Write-Verbose '-------------------------------'
Write-Verbose '--- THIS IS AN INITIALIZER ---'
Write-Verbose '-------------------------------'
6 changes: 3 additions & 3 deletions tests/srcWithManifest/scripts/loader.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Write-Verbose '-------------------------' -Verbose
Write-Verbose '--- THIS IS A LOADER ---' -Verbose
Write-Verbose '-------------------------' -Verbose
Write-Verbose '-------------------------'
Write-Verbose '--- THIS IS A LOADER ---'
Write-Verbose '-------------------------'
Loading