Created
September 9, 2023 19:37
-
-
Save rismoney/ea764e2b8e127de86bc7105e27c96e8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import-module .\Output\g1pwsh\g1pwsh.psm1 | |
Describe "Configure-PSRepository Tests" { | |
BeforeAll { | |
Mock Install-Module -ModuleName "g1pwsh" { | |
param ( | |
[string]$Name, | |
[string]$RequiredVersion, | |
[string]$Scope, | |
[string]$Repository, | |
[switch]$Force | |
) | |
$global:MockedInstallModuleArgs = $PSBoundParameters | |
} | |
Mock Get-PackageSource -Modulename "PackageManagement" { | |
$chocolatey = New-Object PSObject -Property @{ | |
Name = "chocolatey" | |
ProviderName = "NuGet" | |
} | |
$nuget = New-Object PSObject -Property @{ | |
Name = "nuget.org" | |
ProviderName = "NuGet" | |
} | |
$psGalleryVirtual = New-Object PSObject -Property @{ | |
Name = "PSGallery" | |
ProviderName = "NuGet" | |
} | |
$packageSources = @($chocolatey, $nuget, $psGalleryVirtual) | |
} | |
} | |
Context "Installing PowerShellGet" { | |
It "Should install PowerShellGet module with the specified version, scope, and internal repository" { | |
Configure-PSRepository | |
# Verify specific parameter values | |
$global:MockedInstallModuleArgs.Name | Should -Be 'PowerShellGet' | |
$global:MockedInstallModuleArgs.RequiredVersion | Should -Be '2.2.5' | |
$global:MockedInstallModuleArgs.Scope | Should -Be 'AllUsers' | |
$global:MockedInstallModuleArgs.Repository | Should -Be "psgallery-virtual" | |
Should -Invoke -CommandName Install-Module -Modulename "g1pwsh" -Exactly 1 | |
Should -Invoke -CommandName Get-PackageSource -Modulename "g1pwsh" -Exactly 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a function in g1pwsh I am trying to test.