Skip to content

Commit

Permalink
Rework multi-source support test
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanbergstrom committed Jan 29, 2024
1 parent c0dc6cf commit 082c26a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions tests/AnyPackage.Homebrew.Unit.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,32 @@ Describe 'version tests' {
}
}

Describe "multi-source support" {
Describe "error handling" {
BeforeAll {
$altSourceName = 'pyroscope-io/brew'
$altSource = 'pyroscope-io/brew'
$altSourceLocation = 'https://github.com/pyroscope-io/homebrew-brew'
$package = 'pyroscope'

Unregister-PackageSource -Name $altSourceName -ErrorAction SilentlyContinue
}
AfterAll {
Unregister-PackageSource -Name $altSourceName -ErrorAction SilentlyContinue
}

It 'refuses to register a source with no location' {
Register-PackageSource -Name $altSourceName -Provider $providerShortName -ErrorAction SilentlyContinue | Where-Object {$_.Name -eq $altSourceName} | Should -BeNullOrEmpty
It 'refuses to find packages when the specified source does not exist' {
{Find-Package -Name $package -Source $altSource -ErrorAction Stop} | Should -Throw 'The specified source is not registered with the package provider.'
}
It 'refuses to install packages when the specified source does not exist' {
{Install-Package -Name $package -Source $altSource -ErrorAction Stop} | Should -Throw 'The specified source is not registered with the package provider.'
}
It 'registers an alternative package source' {
Register-PackageSource -Name $altSourceName -Location $altSourceLocation -Provider $providerShortName | Where-Object {$_.Name -eq $altSourceName} | Should -Not -BeNullOrEmpty
Register-PackageSource -Name $altSourceName -Location $altSourceLocation -Provider $providerShortName -PassThru | Where-Object {$_.Name -eq $altSourceName} | Should -Not -BeNullOrEmpty
}
It 'searches for and installs the latest version of a package from an alternate source' {
Find-Package -Name $package -Source $altSourceName | Install-Package -PassThru | Where-Object {$_.Name -contains $package} | Should -Not -BeNullOrEmpty
}
It 'unregisters an alternative package source' {
Unregister-PackageSource -Name $altSourceName
Get-PackageSource | Where-Object {$_.Name -eq $altSourceName} | Should -BeNullOrEmpty
}
}
}

0 comments on commit 082c26a

Please sign in to comment.