Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
retrofitted a couple test files
Browse files Browse the repository at this point in the history
  • Loading branch information
mwrock committed Oct 30, 2012
1 parent fcc68ba commit 05fb3c7
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 73 deletions.
32 changes: 6 additions & 26 deletions tests/Chocolatey-NuGet.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,22 @@ $common = Join-Path $here '_Common.ps1'
. $common

Describe "When calling Chocolatey-NuGet normally" {
Initialize-Variables
$script:exec_chocolatey_nuget_actual = $true
$script:exec_update_sessionenvironment_actual = $false
Mock Run-NuGet {""} -Verifiable -ParameterFilter {$packageName -eq 'somepackage'}

Chocolatey-NuGet 'somepackage'

It "should call Chocolatey-NuGet" {
$script:chocolatey_nuget_was_called.should.be($true)
}

It "should call Run-NuGet" {
$script:run_nuget_was_called.should.be($true)
}
It "should call Start-Process function to run NuGet.exe" {
#$script:start_process_was_called.should.be($true)
}

Assert-VerifiableMocks
}
}

Describe "when calling Chocolatey-NuGet with packageName 'all'" {
Initialize-Variables
$script:exec_chocolatey_nuget_actual = $true
$script:exec_update_sessionenvironment_actual = $false
Mock Chocolatey-InstallAll {} -Verifiable -ParameterFilter {$source -eq 'source'}

Chocolatey-NuGet 'all'
Chocolatey-NuGet 'all' 'source'

It "should call Chocolatey-NuGet" {
$script:chocolatey_nuget_was_called.should.be($true)
}

It "should call Chocolatey-InstallAll" {
$script:chocolatey_installall_was_called.should.be($true)
}

It "should set packageName appropriately" {
$script:packageName.should.be('all')
Assert-VerifiableMocks
}

}
4 changes: 0 additions & 4 deletions tests/_FunctionRenameActuals.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
rename-item function:Update-SessionEnvironment Update-SessionEnvironment-Actual
rename-item function:Chocolatey-Help Chocolatey-Help-Actual
rename-item function:Chocolatey-Install Chocolatey-Install-Actual
rename-item function:Chocolatey-InstallAll Chocolatey-InstallAll-Actual
rename-item function:Chocolatey-InstallIfMissing Chocolatey-InstallIfMissing-Actual
rename-item function:Chocolatey-List Chocolatey-List-Actual
rename-item function:Chocolatey-Nuget Chocolatey-Nuget-Actual
rename-item function:Chocolatey-Pack Chocolatey-Pack-Actual
rename-item function:Chocolatey-PackagesConfig Chocolatey-PackagesConfig-Actual
rename-item function:Chocolatey-Push Chocolatey-Push-Actual
Expand All @@ -26,9 +24,7 @@ rename-item function:Get-PackageFolderVersions Get-PackageFolderVersions-Actual
rename-item function:Get-PackageFoldersForPackage Get-PackageFoldersForPackage-Actual
rename-item function:Get-VersionsForComparison Get-VersionsForComparison-Actual
rename-item function:Remove-LastInstallLog Remove-LastInstallLog-Actual
rename-item function:Run-ChocolateyPS1 Run-ChocolateyPS1-Actual
rename-item function:Run-ChocolateyProcess Run-ChocolateyProcess-Actual
rename-item function:Run-NuGet Run-NuGet-Actual

rename-item function:Get-ChocolateyUnzip Get-ChocolateyUnzip-Actual
rename-item function:Get-ChocolateyWebFile Get-ChocolateyWebFile-Actual
Expand Down
20 changes: 0 additions & 20 deletions tests/functions/Chocolatey-Nuget.ps1

This file was deleted.

16 changes: 0 additions & 16 deletions tests/functions/Run-ChocolateyPS1.ps1

This file was deleted.

16 changes: 9 additions & 7 deletions tests/unit/Run-ChocolateyPS1.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@ $here = Split-Path -Parent $MyInvocation.MyCommand.Definition
$common = Join-Path (Split-Path -Parent $here) '_Common.ps1'
. $common

function ChocolateyInstall {
$global:installArgsInEnvironment=$env:chocolateyInstallArguments
}

Describe "When calling Run-Chocolatey.ps1 with Installer Arguments" {
Initialize-Variables
$script:exec_run_chocolateyps1_actual = $true
$global:installArgsInEnvironment = 'fake args'
mkdir $env:temp\test | Out-Null
new-item $env:temp\test\ChocolateyInstall.ps1 -ItemType file -value "`$global:installArgsInEnvironment=`$env:chocolateyInstallArguments" | Out-Null
Run-ChocolateyPS1 $env:temp\test 'testPackage' 'install' 'real args'
Remove-Item $env:temp\test -Recurse -Force
$cmd=(Get-Command ChocolateyInstall)
Mock Get-ChildItem {return @{Name="chocolateyinstall.ps1";FullName=$cmd}} -ParameterFilter {$path -eq "$env:temp\test"}

Run-ChocolateyPS1 "$env:temp\test" 'testPackage' 'install' 'real args'

It "should set chocolateyInstallArguments env var to Installer Arguments" {
$global:installArgsInEnvironment.should.be('real args')
}
}

0 comments on commit 05fb3c7

Please sign in to comment.