8000 Add an additional acceptance test for the PowerShellGet module by bmanikm · Pull Request #4531 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Add an additional acceptance test for the PowerShellGet module #4531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
8000
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
0