From b767eb01fade549436c51c90eae37831b20ff3da Mon Sep 17 00:00:00 2001 From: Xin Huang Date: Thu, 18 Apr 2013 20:01:33 +0800 Subject: [PATCH] add support to install msu. --- .../Install-ChocolateyInstallPackage.ps1 | 10 ++++++++++ .../Install-ChocolateyInstallPackage.Tests.ps1 | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/unit/Install-ChocolateyInstallPackage.Tests.ps1 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