-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample_script.tests.ps1
More file actions
39 lines (30 loc) · 946 Bytes
/
sample_script.tests.ps1
File metadata and controls
39 lines (30 loc) · 946 Bytes
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
BeforeAll {
. "$PSScriptRoot/../../src/testing/test_utils_lib.ps1"
$cmd = "$PSScriptRoot/../../src/env/sample_script.ps1"
}
Describe 'sample_script facade' {
BeforeEach {
$params = @{
name = 'foo;bar'
greeting = 'hi {0}'
outputFile = (Get-FullPath 'TestDrive:/out.json')
}
}
It 'Saves result to dedicated file' {
& $cmd @params
$params.outputFile | Should -Exist
Get-Content $params.outputFile | ConvertFrom-Json | Should -Not -BeNullOrEmpty
}
It 'Does not save anything if file path not provided' {
Mock Out-File
$params.outputFile = ''
& $cmd @params
Should -Not -Invoke Out-File
$params.outputFile | Should -Not -Exist
}
AfterEach {
if (Test-Path $params.outputFile -PathType Leaf) {
Remove-Item $params.outputFile -Force | Out-Null
}
}
}