tests/Get-DbaAgentAlert.Tests.ps1
#Thank you Warren http://ramblingcookiemonster.github.io/Testing-DSC-with-Pester-and-AppVeyor/ if(-not $PSScriptRoot) { $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent } $Verbose = @{} if($env:APPVEYOR_REPO_BRANCH -and $env:APPVEYOR_REPO_BRANCH -notlike "master") { $Verbose.add("Verbose",$True) } $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace('.Tests.', '.') Import-Module $PSScriptRoot\..\functions\$sut -Force Import-Module PSScriptAnalyzer ## Added PSAvoidUsingPlainTextForPassword as credential is an object and therefore fails. We can ignore any rules here under special circumstances agreed by admins :-) $Rules = (Get-ScriptAnalyzerRule).Where{$_.RuleName -notin ('PSAvoidUsingPlainTextForPassword') } $Name = $sut.Split('.')[0] Describe 'Script Analyzer Tests' { Context "Testing $Name for Standard Processing" { foreach ($rule in $rules) { $i = $rules.IndexOf($rule) It "passes the PSScriptAnalyzer Rule number $i - $rule " { (Invoke-ScriptAnalyzer -Path "$PSScriptRoot\..\functions\$sut" -IncludeRule $rule.RuleName ).Count | Should Be 0 } } } } ## needs some proper tests for the function here Describe "$Name Tests"{ Context "Some Tests" { It "Should have some Pester Tests added" { $true | Should Be $true } } } |