Skip to content

Commit

Permalink
restrict the nested reboots only if reboots are ok
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Sep 24, 2014
1 parent acadc65 commit 4c374f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Boxstarter.Chocolatey/Chocolatey.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Intercepts Chocolatey call to check for reboots
$winFeature=$true
}
}
if((Test-PendingReboot) -and $Boxstarter.RebootOk -or $Boxstarter.IsRebooting) {return Invoke-Reboot}
if(((Test-PendingReboot) -or $Boxstarter.IsRebooting) -and $Boxstarter.RebootOk) {return Invoke-Reboot}
$session=Start-TimedSection "Calling Chocolatey to install $packageName. This may take several minutes to complete..."
try {
if($winFeature -eq $true -and (Get-IsRemote)){
Expand Down
8 changes: 3 additions & 5 deletions tests/Chocolatey/Chocolatey.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Describe "Getting-Chocolatey" {
}
it "will not get Chocolatey" {
Assert-MockCalled Call-Chocolatey -times 0
}
}
$Boxstarter.IsRebooting=$false
}

Context "When a reboot is pending but reboots are not OK" {
Expand Down Expand Up @@ -199,15 +200,12 @@ Describe "Getting-Chocolatey" {
Mock Test-PendingReboot {return $false}
Mock Invoke-Reboot
Mock Call-Chocolatey {$global:LASTEXITCODE=1}
$Boxstarter.IsRebooting=$false

$error = Chocolatey Install pkg 2>&1

it "will write an error" {
$error| should match "Chocolatey reported an unsuccessful exit code of 1"
}
}

#Not sure why I need to do this but pester test drive cleanup
#does not properly cleanup without it
#Remove-Item $TestDrive -recurse -force
}

0 comments on commit 4c374f8

Please sign in to comment.