diff --git a/src/helpers/functions/Install-ChocolateyInstallPackage.ps1 b/src/helpers/functions/Install-ChocolateyInstallPackage.ps1 index 7a00d0b..48a6887 100644 --- a/src/helpers/functions/Install-ChocolateyInstallPackage.ps1 +++ b/src/helpers/functions/Install-ChocolateyInstallPackage.ps1 @@ -76,5 +76,15 @@ param( } } + if($fileType -like 'msu') { + + if ($overrideArguments) { + $msuArgs = "$file $additionalInstallArgs" + } else { + $msuArgs = "$file $silentArgs $additionalInstallArgs" + } + Start-ChocolateyProcessAsAdmin "$msuArgs" 'wusa.exe' -validExitCodes $validExitCodes + } + write-host "$packageName has been installed." } \ No newline at end of file diff --git a/tests/unit/Install-ChocolateyInstallPackage.Tests.ps1 b/tests/unit/Install-ChocolateyInstallPackage.Tests.ps1 new file mode 100644 index 0000000..c918386 --- /dev/null +++ b/tests/unit/Install-ChocolateyInstallPackage.Tests.ps1 @@ -0,0 +1,18 @@ +$here = Split-Path -Parent $MyInvocation.MyCommand.Definition +$common = Join-Path (Split-Path -Parent $here) '_Common.ps1' +$base = Split-Path -parent (Split-Path -Parent $here) + +. $common +. "$base\src\helpers\functions\Install-ChocolateyInstallPackage.ps1" + +Describe "Install-ChocolateyInstallPackage" { + Context "When file type is msu" { + Mock Start-ChocolateyProcessAsAdmin + + Install-ChocolateyInstallPackage "package" "msu" + It "should be installed" { + Assert-MockCalled Start-ChocolateyProcessAsAdmin + } + } + +} \ No newline at end of file