Skip to content
Merged
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
16 changes: 15 additions & 1 deletion scripts/tests/PSModule/SourceCode.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ BeforeAll {

Describe 'PSModule - SourceCode tests' {
Context 'function/filter' {
It 'Should contain one function or filter' {
$issues = @('')
$functionFiles | ForEach-Object {
$path = $_.FullName
$Ast = [System.Management.Automation.Language.Parser]::ParseFile($path, [ref]$null, [ref]$null)
$tokens = $Ast.FindAll( { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] } , $true )
if ($tokens.count -ne 1) {
$issues += " - $path"
}
}
$issues -join [Environment]::NewLine |
Should -BeNullOrEmpty -Because 'the script should contain one function or filter'
}

It 'Script filename and function/filter name should match' {
$scriptFiles = @()
Get-ChildItem -Path $Path -Filter '*.ps1' -Recurse -File | ForEach-Object {
Expand All @@ -44,7 +58,7 @@ Describe 'PSModule - SourceCode tests' {
Should -BeNullOrEmpty -Because 'the script files should be called the same as the function they contain'
}

# It 'Script file should only contain one function or filter' {}


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

Expand Down