|
136 | 136 | }
|
137 | 137 | }
|
138 | 138 |
|
139 |
| - It "Validate errors from Compress-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" -ForEach @( |
140 |
| - @{ Path = "TestDrive:/InvalidPath" } |
141 |
| - @{ Path = @("TestDrive:/", "TestDrive:/InvalidPath") } |
142 |
| - ) { |
| 139 | + It "Validate errors from Compress-Archive when invalid path is supplied for Path or LiteralPath parameters" -ForEach @( |
| 140 | + @{ Path = "Env:/Path" } |
| 141 | + @{ Path = @("TestDrive:/", "Env:/Path") } |
| 142 | + ) -Tag this1 { |
143 | 143 | $DestinationPath = "TestDrive:/archive2.zip"
|
144 | 144 |
|
| 145 | + Compress-Archive -Path $Path -DestinationPath $DestinationPath -ErrorAction SilentlyContinue -ErrorVariable error |
| 146 | + $error.Count | Should -Be 1 |
| 147 | + $error[0].FullyQualifiedErrorId | Should -Be "InvalidPath,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
| 148 | + Remove-Item -Path $DestinationPath |
| 149 | + |
| 150 | + Compress-Archive -LiteralPath $Path -DestinationPath $DestinationPath -ErrorAction SilentlyContinue -ErrorVariable error |
| 151 | + $error.Count | Should -Be 1 |
| 152 | + $error[0].FullyQualifiedErrorId | Should -Be "InvalidPath,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
| 153 | + Remove-Item -Path $DestinationPath |
| 154 | + } |
| 155 | + |
| 156 | + It "Throws terminating error when non-existing path is supplied for Path or LiteralPath parameters" -ForEach @( |
| 157 | + @{ Path = "TestDrive:/DoesNotExist" } |
| 158 | + @{ Path = @("TestDrive:/", "TestDrive:/DoesNotExist") } |
| 159 | + ) -Tag this2 { |
| 160 | + $DestinationPath = "TestDrive:/archive3.zip" |
| 161 | + |
145 | 162 | try
|
146 |
| - { |
147 |
| - Compress-Archive -Path $Path -DestinationPath $DestinationPath |
148 |
| - throw "Failed to validate that an invalid Path was supplied as input to Compress-Archive cmdlet." |
149 |
| - } |
150 |
| - catch |
151 |
| - { |
152 |
| - $_.FullyQualifiedErrorId | Should -Be "PathNotFound,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
153 |
| - } |
| 163 | + { |
| 164 | + Compress-Archive -Path $Path -DestinationPath $DestinationPath |
| 165 | + throw "Failed to validate that an invalid Path was supplied as input to Compress-Archive cmdlet." |
| 166 | + } |
| 167 | + catch |
| 168 | + { |
| 169 | + $_.FullyQualifiedErrorId | Should -Be "PathNotFound,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
| 170 | + } |
154 | 171 |
|
155 |
| - try |
156 |
| - { |
157 |
| - Compress-Archive -LiteralPath $Path -DestinationPath $DestinationPath |
158 |
| - throw "Failed to validate that an invalid LiteralPath was supplied as input to Compress-Archive cmdlet." |
159 |
| - } |
160 |
| - catch |
161 |
| - { |
162 |
| - $_.FullyQualifiedErrorId | Should -Be "PathNotFound,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
163 |
| - } |
| 172 | + try |
| 173 | + { |
| 174 | + Compress-Archive -LiteralPath $Path -DestinationPath $DestinationPath |
| 175 | + throw "Failed to validate that an invalid LiteralPath was supplied as input to Compress-Archive cmdlet." |
| 176 | + } |
| 177 | + catch |
| 178 | + { |
| 179 | + $_.FullyQualifiedErrorId | Should -Be "PathNotFound,Microsoft.PowerShell.Archive.CompressArchiveCommand" |
| 180 | + } |
164 | 181 | }
|
165 | 182 |
|
166 | 183 | It "Validate error from Compress-Archive when duplicate paths are supplied as input to Path parameter" {
|
|
0 commit comments