mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Use new Pester syntax: -Parameter for Pester tests in modules: PowerShellGet, PackageManagement, PSReadLine (#6488)
This commit is contained in:
@@ -11,43 +11,43 @@ Describe "PSReadLine" -tags "CI" {
|
||||
It "Should import the module correctly" {
|
||||
Import-Module PSReadLine
|
||||
$module = Get-Module PSReadLine
|
||||
$module.Name | Should Be "PSReadLine"
|
||||
$module.Version | Should Be "1.2"
|
||||
$module.Name | Should -BeExactly 'PSReadLine'
|
||||
$module.Version | Should -BeExactly '1.2'
|
||||
}
|
||||
|
||||
It "Should use Emacs Bindings on Linux and macOS" -skip:$IsWindows {
|
||||
(Get-PSReadLineOption).EditMode | Should Be Emacs
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be BeginningOfLine
|
||||
(Get-PSReadLineOption).EditMode | Should -BeExactly 'Emacs'
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should -BeExactly 'BeginningOfLine'
|
||||
}
|
||||
|
||||
It "Should use Windows Bindings on Windows" -skip:(-not $IsWindows) {
|
||||
(Get-PSReadLineOption).EditMode | Should Be Windows
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+a" }).Function | Should Be SelectAll
|
||||
(Get-PSReadLineOption).EditMode | Should -BeExactly 'Windows'
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+a" }).Function | Should -BeExactly 'SelectAll'
|
||||
}
|
||||
|
||||
It "Should set the edit mode" {
|
||||
Set-PSReadlineOption -EditMode Windows
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be SelectAll
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should -BeExactly 'SelectAll'
|
||||
|
||||
Set-PSReadlineOption -EditMode Emacs
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should Be BeginningOfLine
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+A" }).Function | Should -BeExactly 'BeginningOfLine'
|
||||
}
|
||||
|
||||
It "Should allow custom bindings for plain keys" {
|
||||
Set-PSReadlineKeyHandler -Key '"' -Function SelfInsert
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq '"' }).Function | Should Be SelfInsert
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -eq '"' }).Function | Should -BeExactly 'SelfInsert'
|
||||
}
|
||||
|
||||
It "Should report Capitalized bindings correctly" {
|
||||
Set-PSReadlineOption -EditMode Emacs
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+b" }).Function | Should Be BackwardWord
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+B" }).Function | Should Be SelectBackwardWord
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+b" }).Function | Should -BeExactly 'BackwardWord'
|
||||
(Get-PSReadLineKeyHandler | Where-Object { $_.Key -ceq "Alt+B" }).Function | Should -BeExactly 'SelectBackwardWord'
|
||||
}
|
||||
|
||||
It "Should ignore case when using Function binding" {
|
||||
$lowerCaseFunctionName = "yank"
|
||||
Set-PSReadlineKeyHandler "Ctrl+F24" -Function $lowerCaseFunctionName
|
||||
(Get-PSReadlineKeyHandler | Where { $_.Key -eq "Ctrl+F24"}).Function | Should Be "Yank"
|
||||
(Get-PSReadlineKeyHandler | Where-Object { $_.Key -eq "Ctrl+F24"}).Function | Should -BeExactly "Yank"
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
|
||||
@@ -31,43 +31,43 @@ Describe "PackageManagement Acceptance Test" -Tags "Feature" {
|
||||
|
||||
$gpp = Get-PackageProvider
|
||||
|
||||
$gpp | Where-Object { $_.name -eq "NuGet" } | should not BeNullOrEmpty
|
||||
$gpp.Name | Should -Contain 'NuGet'
|
||||
|
||||
$gpp | Where-Object { $_.name -eq "PowerShellGet" } | should not BeNullOrEmpty
|
||||
$gpp.Name | Should -Contain 'PowerShellGet'
|
||||
}
|
||||
|
||||
It "find-packageprovider PowerShellGet" {
|
||||
$fpp = (Find-PackageProvider -Name "PowerShellGet" -force).name
|
||||
$fpp -contains "PowerShellGet" | should be $true
|
||||
$fpp | Should -Contain "PowerShellGet"
|
||||
}
|
||||
|
||||
It "install-packageprovider, Expect succeed" {
|
||||
$ipp = (install-PackageProvider -name gistprovider -force -source $InternalSource -Scope CurrentUser).name
|
||||
$ipp -contains "gistprovider" | should be $true
|
||||
$ipp | Should -Contain "gistprovider"
|
||||
}
|
||||
|
||||
it "Find-package" {
|
||||
$f = Find-Package -ProviderName NuGet -Name jquery -source Nugettest
|
||||
$f.Name -contains "jquery" | should be $true
|
||||
$f.Name | Should -Contain "jquery"
|
||||
}
|
||||
|
||||
it "Install-package" {
|
||||
$i = install-Package -ProviderName NuGet -Name jquery -force -source Nugettest -Scope CurrentUser
|
||||
$i.Name -contains "jquery" | should be $true
|
||||
$i.Name | Should -Contain "jquery"
|
||||
}
|
||||
|
||||
it "Get-package" {
|
||||
$g = Get-Package -ProviderName NuGet -Name jquery
|
||||
$g.Name -contains "jquery" | should be $true
|
||||
$g.Name | Should -Contain "jquery"
|
||||
}
|
||||
|
||||
it "save-package" {
|
||||
$s = save-Package -ProviderName NuGet -Name jquery -path $TestDrive -force -source Nugettest
|
||||
$s.Name -contains "jquery" | should be $true
|
||||
$s.Name | Should -Contain "jquery"
|
||||
}
|
||||
|
||||
it "uninstall-package" {
|
||||
$u = uninstall-Package -ProviderName NuGet -Name jquery
|
||||
$u.Name -contains "jquery" | should be $true
|
||||
$u.Name | Should -Contain "jquery"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,21 +123,21 @@ Describe "PowerShellGet - Module tests" -tags "Feature" {
|
||||
|
||||
It "Should find a module correctly" {
|
||||
$psgetModuleInfo = Find-Module -Name $ContosoServer -Repository $RepositoryName
|
||||
$psgetModuleInfo.Name | Should Be $ContosoServer
|
||||
$psgetModuleInfo.Repository | Should Be $RepositoryName
|
||||
$psgetModuleInfo.Name | Should -Be $ContosoServer
|
||||
$psgetModuleInfo.Repository | Should -Be $RepositoryName
|
||||
}
|
||||
|
||||
It "Should install a module correctly to the required location with CurrentUser scope" {
|
||||
Install-Module -Name $ContosoServer -Repository $RepositoryName -Scope CurrentUser
|
||||
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
||||
|
||||
$installedModuleInfo | Should Not Be $null
|
||||
$installedModuleInfo.Name | Should Be $ContosoServer
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true
|
||||
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
||||
$installedModuleInfo.Name | Should -Be $ContosoServer
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:MyDocumentsModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
|
||||
$module = Get-Module $ContosoServer -ListAvailable
|
||||
$module.Name | Should be $ContosoServer
|
||||
$module.ModuleBase | Should Be $installedModuleInfo.InstalledLocation
|
||||
$module.Name | Should -Be $ContosoServer
|
||||
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -163,13 +163,13 @@ Describe "PowerShellGet - Module tests (Admin)" -tags @('Feature', 'RequireAdmin
|
||||
Install-Module -Name $ContosoServer -Repository $RepositoryName
|
||||
$installedModuleInfo = Get-InstalledModule -Name $ContosoServer
|
||||
|
||||
$installedModuleInfo | Should Not Be $null
|
||||
$installedModuleInfo.Name | Should Be $ContosoServer
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:programFilesModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true
|
||||
$installedModuleInfo | Should -Not -BeNullOrEmpty
|
||||
$installedModuleInfo.Name | Should -Be $ContosoServer
|
||||
$installedModuleInfo.InstalledLocation.StartsWith($script:programFilesModulesPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
|
||||
$module = Get-Module $ContosoServer -ListAvailable
|
||||
$module.Name | Should be $ContosoServer
|
||||
$module.ModuleBase | Should Be $installedModuleInfo.InstalledLocation
|
||||
$module.Name | Should -Be $ContosoServer
|
||||
$module.ModuleBase | Should -Be $installedModuleInfo.InstalledLocation
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -197,17 +197,17 @@ Describe "PowerShellGet - Script tests" -tags "Feature" {
|
||||
|
||||
It "Should find a script correctly" {
|
||||
$psgetScriptInfo = Find-Script -Name $FabrikamServerScript -Repository $RepositoryName
|
||||
$psgetScriptInfo.Name | Should Be $FabrikamServerScript
|
||||
$psgetScriptInfo.Repository | Should Be $RepositoryName
|
||||
$psgetScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$psgetScriptInfo.Repository | Should -Be $RepositoryName
|
||||
}
|
||||
|
||||
It "Should install a script correctly to the required location with CurrentUser scope" {
|
||||
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -Scope CurrentUser -NoPathUpdate
|
||||
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
||||
|
||||
$installedScriptInfo | Should Not Be $null
|
||||
$installedScriptInfo.Name | Should Be $FabrikamServerScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:MyDocumentsScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true
|
||||
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
||||
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:MyDocumentsScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -233,9 +233,9 @@ Describe "PowerShellGet - Script tests (Admin)" -tags @('Feature', 'RequireAdmin
|
||||
Install-Script -Name $FabrikamServerScript -Repository $RepositoryName -NoPathUpdate
|
||||
$installedScriptInfo = Get-InstalledScript -Name $FabrikamServerScript
|
||||
|
||||
$installedScriptInfo | Should Not Be $null
|
||||
$installedScriptInfo.Name | Should Be $FabrikamServerScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true
|
||||
$installedScriptInfo | Should -Not -BeNullOrEmpty
|
||||
$installedScriptInfo.Name | Should -Be $FabrikamServerScript
|
||||
$installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should -BeTrue
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
@@ -269,8 +269,8 @@ Describe 'PowerShellGet Type tests' -tags @('CI') {
|
||||
$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 }
|
||||
$Type | Select-Object -ExpandProperty Name | Should -Be $ClassName
|
||||
$_.Value | ForEach-Object { $Type.DeclaredMembers.Name -contains $_ | Should -BeTrue }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user