-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUcmPSTools.Tests.ps1
51 lines (32 loc) · 1.96 KB
/
UcmPSTools.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#Thanks to Adam the Automater for these wicked pipeline tools
#Check out https://adamtheautomator.com/powershell-devops/ for more info!
#Also check out his book "The Pester Book. It helped me write all these tests!
#Install-Module -Name PSScriptAnalyzer -Force
describe 'Module-level tests' {
it 'the module imports successfully' {
{ Import-Module -name "$PSScriptRoot\UcmPSTools.psm1" -ErrorAction Stop } | should -not -throw
}
it 'the module has an associated manifest' {
Test-Path "$PSScriptRoot\UcmPSTools.psd1" | should -Be $true
}
it 'passes all default PSScriptAnalyzer rules' {
Invoke-ScriptAnalyzer -Path "$PSScriptRoot\UcmPSTools.psm1" | should -BeNullOrEmpty
}
}
<#describe 'Write-UcmLog tests' {
$TestPath = "TestDrive:\Testlog.log"
$Global:LogFileLocation = $TestPath
#Import Write-UcmLog
import-module $PSScriptRoot\public\Write-UcmLog.ps1
Write-UcmLog -Message "Creating Pester Test File" -Severity 1 -Component "Pester"
Get-Content -path $testPath
it 'Creates a log file' {(Get-Content -path $testPath)} | should -not -throw
it 'Writes to the log file' {(Get-Content -path $testPath)} | should -contain "Pester"
<# it 'Displays a verbose message' { $(Write-UcmLog -Message "Pester Test Verbose Message" -Severity 1 -Component "Pester")4>&1 }| Should -eq 'Pester Test Verbose Message'
it 'Displays an info message' { $(Write-UcmLog -Message "Pester Test Info Message" -Severity 3 -Component "Pester") }| Should -eq 'Pester Test Info Message'
it 'Displays a warning message' { $(Write-UcmLog -Message "Pester Test Warning Message" -Severity 3 -Component "Pester")3>&1 }| Should -eq 'Pester Test Warning Message'
it 'Displays an error message' { $(Write-UcmLog -Message "Pester Test Error Message" -Severity 4 -Component "Pester")2>&1 }| Should -eq 'Pester Test Error Message'
it 'Injects the function name' { $(Write-UcmLog -Message "Testing Function Test" -Severity 2 -Component "Pester") }| Should -eq 'Pester'
#it 'Rotates the log file' {}
}
#>