Skip to content

Commit

Permalink
(#3461,#3487) Add an all packages source for tests
Browse files Browse the repository at this point in the history
We have added some tests for the install all command. This adds a new
package source to the testing environment so that we can run the tests
locally and in Test Kitchen.
  • Loading branch information
corbob committed Aug 15, 2024
1 parent cd49547 commit 21544e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Invoke-Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,34 @@ else {
if (-not (Test-Path "$TestPath/packages") -or -not $SkipPackaging) {
$null = New-Item -Path "$TestPath/packages" -ItemType Directory -Force
# Get and pack packages
$nuspecs = Get-ChildItem -Path $PSScriptRoot/src/chocolatey.tests.integration, $PSScriptRoot/tests/packages -Recurse -Include *.nuspec | Where-Object FullName -notmatch 'bin'
$nuspecs = Get-ChildItem -Path $PSScriptRoot/src/chocolatey.tests.integration, $PSScriptRoot/tests/packages -Recurse -Include *.nuspec | Where-Object FullName -NotMatch 'bin'
Get-ChildItem -Path $PSScriptRoot/tests/packages -Recurse -Include *.nupkg | Copy-Item -Destination "$TestPath/packages"

foreach ($file in $nuspecs) {
Write-Host "Packaging $file"
$null = choco pack $file.FullName --out "$TestPath/packages"
# Include allow-unofficial in case an unofficial Chocolatey has been installed globally for testing
$null = choco pack $file.FullName --out "$TestPath/packages" --allow-unofficial
}
}

if (-not (Test-Path "$TestPath/all-packages") -or -not $SkipPackaging) {
$null = New-Item -Path "$TestPath/all-packages" -ItemType Directory -Force

# These are the package ids that are loaded into the all packages test repository.
$AllPackagesRepository = @(
'isdependency'
'hasdependency'
'hasnesteddependency'
# These packages may be causing issues with the install all...
'downgradesdependency'
'dependencyfailure'
'hasfailingnesteddependency'
'failingdependency'
'isexactversiondependency'
)

foreach ($package in $AllPackagesRepository) {
$null = Copy-Item "$TestPath/packages/$package.*.nupkg" "$TestPath/all-packages/"
}
}

Expand Down Expand Up @@ -97,6 +119,7 @@ try {

Import-Module $PSScriptRoot\tests\helpers\common-helpers.psm1 -Force
$null = Invoke-Choco source add --name hermes --source "$TestPath/packages"
$null = Invoke-Choco source add --name hermes-all --source "$TestPath/all-packages"
Enable-ChocolateyFeature -Name allowGlobalConfirmation
$PesterConfiguration = [PesterConfiguration]@{
Run = @{
Expand Down
1 change: 1 addition & 0 deletions tests/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", name: "clear-packages", inline: <<-SHELL
Write-Host "($(Get-Date -Format "dddd MM/dd/yyyy HH:mm:ss K")) Clearing the packages directory"
Remove-Item "$env:TEMP/chocolateyTests/packages" -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item "$env:TEMP/chocolateyTests/all-packages" -Recurse -Force -ErrorAction SilentlyContinue
SHELL
config.vm.provision "shell", name: "test", inline: <<-SHELL
# Copy changed files.
Expand Down

0 comments on commit 21544e7

Please sign in to comment.