-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGet-PVFileList.Tests.ps1
79 lines (47 loc) · 1.45 KB
/
Get-PVFileList.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#Get Current Directory
$Here = Split-Path -Parent $MyInvocation.MyCommand.Path
#Get Function Name
$FunctionName = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -Replace ".Tests.ps1"
#Assume ModuleName from Repository Root folder
$ModuleName = Split-Path (Split-Path $Here -Parent) -Leaf
if( -not (Get-Module -Name $ModuleName -All)) {
#Resolve Path to Module Directory
$ModulePath = Resolve-Path "$Here\..\$ModuleName"
#Define Path to Module Manifest
$ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1"
Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop
}
BeforeAll {
#$Script:RequestBody = $null
}
AfterAll {
#$Script:RequestBody = $null
}
Describe $FunctionName {
InModuleScope $ModuleName {
Context "Default" {
BeforeEach {
$InputObj = [PSCustomObject]@{
safeName = "SomeSafe"
folder = "SomeFile"
}
$Password = ConvertTo-SecureString "SomePassword" -AsPlainText -Force
Mock Invoke-PACLICommand -MockWith {
[PSCustomObject]@{
StdOut = $((((1..20) * 7 -join '" "') -replace '^', '"') -replace '$', '"')
ExitCode = 0
}
}
}
It "executes without exception" {
{ $InputObj | Get-PVFileList } | Should Not throw
}
It "invokes expected pacli command" {
$InputObj | Get-PVFileList
Assert-MockCalled Invoke-PACLICommand -Times 1 -Exactly -Scope It -ParameterFilter {
$PacliCommand -eq "FILESLIST"
}
}
}
}
}