File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
tests/PesterExtensions/Public Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,30 @@ Describe 'Mock an environment variable' {
5353 }
5454 }
5555
56+ Describe ' Restore variable that got destroyed' {
57+ BeforeAll {
58+ $script :environmentVariableName = " test$ ( New-Guid ) "
59+ $script :environmentVariable = " env:${environmentVariableName} "
60+ $script :InitialValue = ' Some value here and there'
61+ $script :UpdatedValue = ' Some updated value'
62+ New-Item - Path $environmentVariable - Value $InitialValue
63+ Mock- EnvironmentVariable - Variable $environmentVariableName - Value $UpdatedValue {
64+ Remove-Item - Path $environmentVariable - Recurse - Force - ErrorAction Ignore
65+ }
66+ }
67+ It ' Environment variable is set up' {
68+ (Get-ChildItem - Path $environmentVariable ).Value | Should - Be $InitialValue
69+ }
70+ AfterAll {
71+ Remove-Item `
72+ - Path $environmentVariable `
73+ - Force `
74+ - Recurse `
75+ - ErrorAction Ignore
76+ }
77+
78+ }
79+
5680 Describe ' Initial value should be reasigned' {
5781 BeforeAll {
5882 $script :environmentVariableName = " test$ ( New-Guid ) "
You can’t perform that action at this time.
0 commit comments