Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion test/powershell/Modules/PowerShellGet/PowerShellGet.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function Initialize

function Remove-InstalledModules
{
Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | Uninstall-Module -Force
Get-InstalledModule -Name $ContosoServer -AllVersions -ErrorAction SilentlyContinue | PowerShellGet\Uninstall-Module -Force

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might throw right? Do you want to ignore those errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should not be any errors in uninstalling the test module, otherwise other test cases will fail.

}

Describe "PowerShellGet - Module tests" -tags "Feature" {
Expand Down Expand Up @@ -226,6 +226,38 @@ Describe "PowerShellGet - Script tests (Admin)" -tags @('Feature', 'RequireAdmin
}
}

Describe 'PowerShellGet Type tests' -tags @('CI') {
BeforeAll {
Import-Module PowerShellGet -Force
}

It 'Ensure PowerShellGet Types are available' {
$PowerShellGetNamespace = 'Microsoft.PowerShell.Commands.PowerShellGet'
$PowerShellGetTypeDetails = @{
InternalWebProxy = @('GetProxy', 'IsBypassed')
}

if((IsWindows)) {
$PowerShellGetTypeDetails['CERT_CHAIN_POLICY_PARA'] = @('cbSize','dwFlags','pvExtraPolicyPara')
$PowerShellGetTypeDetails['CERT_CHAIN_POLICY_STATUS'] = @('cbSize','dwError','lChainIndex','lElementIndex','pvExtraPolicyStatus')
$PowerShellGetTypeDetails['InternalSafeHandleZeroOrMinusOneIsInvalid'] = @('IsInvalid')
$PowerShellGetTypeDetails['InternalSafeX509ChainHandle'] = @('CertFreeCertificateChain','ReleaseHandle','InvalidHandle')
$PowerShellGetTypeDetails['Win32Helpers'] = @('CertVerifyCertificateChainPolicy', 'CertDuplicateCertificateChain', 'IsMicrosoftCertificate')
}

if('Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI' -as [Type]) {
$PowerShellGetTypeDetails['Telemetry'] = @('TraceMessageArtifactsNotFound', 'TraceMessageNonPSGalleryRegistration')
}

$PowerShellGetTypeDetails.GetEnumerator() | ForEach-Object {
$ClassName = $_.Name
$Type = "$PowerShellGetNamespace.$ClassName" -as [Type]
$Type | Select-Object -ExpandProperty Name | Should Be $ClassName
$_.Value | ForEach-Object { $Type.DeclaredMembers.Name -contains $_ | Should Be $true }
}
}
}

if($RegisteredINTRepo)
{
Get-PSRepository -Name $RepositoryName -ErrorAction SilentlyContinue | Unregister-PSRepository
Expand Down