Add all other common module files

This commit is contained in:
Kevin Marquette
2018-07-14 11:17:09 -07:00
parent 01a9c11c8b
commit d26917f9af
7 changed files with 308 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
$Script:ModuleName = 'LDTestFramework'
$Script:ModuleRoot = Split-Path -Path $PSScriptRoot -Parent
Describe "Public commands have comment-based or external help" -Tags 'Build' {
$functions = Get-Command -Module $ModuleName
$help = foreach ($function in $functions) {
Get-Help -Name $function.Name
}
foreach ($node in $help)
{
Context $node.Name {
It "Should have a Description or Synopsis" -Pending {
($node.Description + $node.Synopsis) | Should Not BeNullOrEmpty
}
It "Should have an Example" -Pending {
$node.Examples | Should Not BeNullOrEmpty
}
foreach ($parameter in $node.Parameters.Parameter)
{
if ($parameter -notmatch 'WhatIf|Confirm')
{
It "Should have a Description for Parameter [$($parameter.Name)]" -Pending {
$parameter.Description.Text | Should Not BeNullOrEmpty
}
}
}
}
}
}

View File

@@ -0,0 +1,44 @@
$Script:ModuleName = 'LDTestFramework'
$Script:ModuleRoot = Split-Path -Path (Split-Path -Path $PSScriptRoot -Parent) -Parent
$Script:SourceRoot = Join-Path -Path $ModuleRoot -ChildPath $ModuleName
Describe "All commands pass PSScriptAnalyzer rules" -Tag 'Build' {
$rules = "$ModuleRoot\ScriptAnalyzerSettings.psd1"
$scripts = Get-ChildItem -Path $SourceRoot -Include '*.ps1', '*.psm1', '*.psd1' -Recurse |
Where-Object FullName -notmatch 'Classes'
foreach ($script in $scripts)
{
Context $script.FullName {
$results = Invoke-ScriptAnalyzer -Path $script.FullName -Settings $rules
if ($results)
{
foreach ($rule in $results)
{
It $rule.RuleName -Pending {
$message = "{0} Line {1}: {2}" -f $rule.Severity, $rule.Line, $rule.Message
$message | Should Be ""
}
}
}
else
{
It "Should not fail any rules" {
$results | Should BeNullOrEmpty
}
}
}
}
}
Describe "Public commands have Pester tests" -Tag 'Build' {
$commands = Get-Command -Module $ModuleName
foreach ($command in $commands.Name)
{
$file = Get-ChildItem -Path "$ModuleRoot\Tests" -Include "$command.Tests.ps1" -Recurse
It "Should have a Pester test for [$command]" -Skip:($null -eq $file) {
$file.FullName | Should Not BeNullOrEmpty
}
}
}