Skip to content

Commit dee8d95

Browse files
authored
Merge pull request #773 from alyssa1303/remove-inheritance
Remove unneeded inheritance in InstallHelper.cs
2 parents e799a53 + 4aebaf2 commit dee8d95

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

src/code/InstallHelper.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
2727
/// <summary>
2828
/// Install helper class
2929
/// </summary>
30-
internal class InstallHelper : PSCmdlet
30+
internal class InstallHelper
3131
{
3232
#region Members
3333

@@ -512,7 +512,7 @@ private List<PSResourceInfo> InstallPackage(
512512
_cmdletPassedIn,
513513
out ErrorRecord errorRecord))
514514
{
515-
ThrowTerminatingError(errorRecord);
515+
_cmdletPassedIn.ThrowTerminatingError(errorRecord);
516516
}
517517

518518
if (isModule)
@@ -534,7 +534,7 @@ private List<PSResourceInfo> InstallPackage(
534534
manifestInfo: out Hashtable parsedMetadataHashtable,
535535
error: out Exception manifestReadError))
536536
{
537-
WriteError(
537+
_cmdletPassedIn.WriteError(
538538
new ErrorRecord(
539539
exception: manifestReadError,
540540
errorId: "ManifestFileReadParseError",

test/InstallPSResource.Tests.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,13 @@ Describe 'Test Install-PSResource for Module' {
461461
# Install module that is not authenticode signed
462462
# Should FAIL to install the module
463463
It "Install module that is not authenticode signed" -Skip:(!(Get-IsWindows)) {
464-
Install-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
465-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
464+
{ Install-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
466465
}
466+
467467
# Install 1.4.4.1 (with incorrect catalog file)
468468
# Should FAIL to install the module
469469
It "Install module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
470-
Install-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
471-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
470+
{ Install-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
472471
}
473472

474473
# Install script that is signed
@@ -484,8 +483,7 @@ Describe 'Test Install-PSResource for Module' {
484483
# Install script that is not signed
485484
# Should throw
486485
It "Install script that is not signed" -Skip:(!(Get-IsWindows)) {
487-
Install-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
488-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
486+
{ Install-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
489487
}
490488
}
491489

test/SavePSResource.Tests.ps1

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,13 @@ Describe 'Test Save-PSResource for PSResources' {
257257
# Save module that is not authenticode signed
258258
# Should FAIL to save the module
259259
It "Save module that is not authenticode signed" -Skip:(!(Get-IsWindows)) {
260-
Save-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue
261-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
260+
{ Save-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
262261
}
263262

264263
# Save 1.4.4.1 (with incorrect catalog file)
265264
# Should FAIL to save the module
266265
It "Save module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
267-
Save-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir -ErrorAction SilentlyContinue
268-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
266+
{ Save-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -Path $SaveDir } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
269267
}
270268

271269
# Save script that is signed
@@ -282,8 +280,7 @@ Describe 'Test Save-PSResource for PSResources' {
282280
# Save script that is not signed
283281
# Should throw
284282
It "Save script that is not signed" -Skip:(!(Get-IsWindows)) {
285-
Save-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
286-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
283+
{ Save-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
287284
}
288285

289286
<#

test/UpdatePSResource.Tests.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,7 @@ Describe 'Test Update-PSResource' {
352352
# Should FAIL to update the module
353353
It "Update module with incorrect catalog file" -Skip:(!(Get-IsWindows)) {
354354
Install-PSResource -Name $PackageManagement -Version "1.4.2" -Repository $PSGalleryName -TrustRepository
355-
Update-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
356-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
355+
{ Update-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "TestFileCatalogError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
357356
}
358357

359358
# Update script that is signed
@@ -371,7 +370,6 @@ Describe 'Test Update-PSResource' {
371370
# Should throw
372371
It "Update script that is not signed" -Skip:(!(Get-IsWindows)) {
373372
Install-PSResource -Name "TestTestScript" -Version "1.0" -Repository $PSGalleryName -TrustRepository
374-
Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
375-
$Error[0].FullyQualifiedErrorId | Should -be "InstallPackageFailed,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
373+
{ Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository } | Should -Throw -ErrorId "GetAuthenticodeSignatureError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource"
376374
}
377375
}

0 commit comments

Comments
 (0)