-
Notifications
You must be signed in to change notification settings - Fork 31
/
PSSoftware.Tests.ps1
49 lines (39 loc) · 1.2 KB
/
PSSoftware.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
#region import modules
$ThisModule = "$($MyInvocation.MyCommand.Path -replace '\.Tests\.ps1$', '').psd1"
$ThisModuleName = (($ThisModule | Split-Path -Leaf) -replace '\.psd1')
Get-Module -Name $ThisModuleName -All | Remove-Module -Force
Import-Module -Name $ThisModule -Force -ErrorAction Stop
#endregion
describe 'Module-level tests' {
it 'should validate the module manifest' {
{ Test-ModuleManifest -Path $ThisModule -ErrorAction Stop } | should not throw
}
it 'should pass all error-level script analyzer rules' {
Invoke-ScriptAnalyzer -Path $PSScriptRoot -Severity Error | should benullorempty
}
}
InModuleScope PSSoftware {
}
describe 'New-TempFile' {
$file = New-TempFile
it 'should return FileInfo type' {
$file | should beoftype [System.IO.FileInfo]
}
it 'file should exist' {
Test-Path $file | should betrue
}
Remove-Item $file
}
describe 'Compare-File' {
$file = New-TempFile
"Test " | out-file $file
$file2 = New-TempFile
it 'Should match a file to itself' {
Compare-File $file $file | should beTrue
}
it 'should not match different files' {
Compare-File $file $file2 | should befalse
}
remove-item $file
remove-item $file2
}