Merge pull request #1359 from PowerShell/quoct/onegettest

Enable test for PackageManagement on CorePowerShell
This commit is contained in:
Quoc Truong authored and GitHub committed 2016-07-14 13:26:01 -07:00
commit ac7bed909e
10 files changed
+3259

No files matched your search

@@ -19,6 +19,12 @@
throw new ArgumentNullException("packageSource"); throw new ArgumentNullException("packageSource");
} }
// we cannot call new uri on file path on linux because it will error out
if (System.IO.Directory.Exists(packageSource))
{
return new LocalPackageRepository(packageSource, request);
}
Uri uri = new Uri(packageSource); Uri uri = new Uri(packageSource);
if (uri.IsFile) if (uri.IsFile)
@@ -27,9 +27,13 @@ namespace Microsoft.PackageManagement.Internal.Utility.Platform {
/// </returns> /// </returns>
public static bool IsElevated { public static bool IsElevated {
get { get {
#if LINUX
return string.Equals(System.Environment.GetEnvironmentVariable("SUDO_UID"), "1000");
#else
var id = WindowsIdentity.GetCurrent(); var id = WindowsIdentity.GetCurrent();
var principal = new WindowsPrincipal(id); var principal = new WindowsPrincipal(id);
return principal.IsInRole(WindowsBuiltInRole.Administrator); return principal.IsInRole(WindowsBuiltInRole.Administrator);
#endif
} }
} }
} }
@@ -477,6 +477,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
#region Event and telemetry stuff #region Event and telemetry stuff
//Calling PowerShell Telemetry APIs //Calling PowerShell Telemetry APIs
protected void TraceMessage(string message, SoftwareIdentity swidObject) { protected void TraceMessage(string message, SoftwareIdentity swidObject) {
#if !LINUX
TelemetryAPI.TraceMessage(message, TelemetryAPI.TraceMessage(message,
new { new {
PackageName = swidObject.Name, PackageName = swidObject.Name,
@@ -486,6 +487,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
ExuectionStatus = swidObject.Status, ExuectionStatus = swidObject.Status,
ExecutionTime = DateTime.Today ExecutionTime = DateTime.Today
}); });
#endif
} }
protected enum EventTask { protected enum EventTask {
@@ -508,6 +510,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
protected void LogEvent(EventTask task, EventId id, string context, string name, string version, string providerName, string source, string status, string destinationPath) protected void LogEvent(EventTask task, EventId id, string context, string name, string version, string providerName, string source, string status, string destinationPath)
{ {
#if !LINUX
var iis = InitialSessionState.CreateDefault2(); var iis = InitialSessionState.CreateDefault2();
using (Runspace rs = RunspaceFactory.CreateRunspace(iis)) using (Runspace rs = RunspaceFactory.CreateRunspace(iis))
@@ -535,6 +538,7 @@ namespace Microsoft.PowerShell.PackageManagement.Cmdlets {
} }
} }
} }
#endif
} }
#endregion #endregion
+6
View File
@@ -1,4 +1,10 @@
{ {
"monad/src/oneget/Test/ModuleTests/tests/find-packageprovider.tests.ps1": "powershell/Modules/PackageManagement/Find-PackageProvider.Tests.ps1",
"monad/src/oneget/Test/ModuleTests/tests/get-package.tests.ps1": "powershell/Modules/PackageManagement/Get-Package.Tests.ps1",
"monad/src/oneget/Test/ModuleTests/tests/get-packageprovider.tests.ps1": "powershell/Modules/PackageManagement/Get-PackageProvider.Tests.ps1",
"monad/src/oneget/Test/ModuleTests/tests/import-packageprovider.tests.ps1": "powershell/Modules/PackageManagement/Import-PackageProvider.Tests.ps1",
"monad/src/oneget/Test/ModuleTests/tests/install-packageprovider.tests.ps1": "powershell/Modules/PackageManagement/Install-PackageProvider.Tests.ps1",
"monad/src/oneget/Test/ModuleTests/tests/nuget.tests.ps1": "powershell/Modules/PackageManagement/Nuget.Tests.ps1",
"monad/tests/MultiMachine/Tests/Commands/Cmdlets/Microsoft.PowerShell.Management/Pester.Commands.Cmdlets.Management.TimeZone.Tests.ps1": "powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1", "monad/tests/MultiMachine/Tests/Commands/Cmdlets/Microsoft.PowerShell.Management/Pester.Commands.Cmdlets.Management.TimeZone.Tests.ps1": "powershell/Modules/Microsoft.PowerShell.Management/TimeZone.Tests.ps1",
"monad/tests/MultiMachine/Tests/Commands/Cmdlets/Microsoft.PowerShell.Security/Pester.Commands.Cmdlets.CatalogTests.ps1": "powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1" "monad/tests/MultiMachine/Tests/Commands/Cmdlets/Microsoft.PowerShell.Security/Pester.Commands.Cmdlets.CatalogTests.ps1": "powershell/Modules/Microsoft.PowerShell.Security/FileCatalog.Tests.ps1"
} }
@@ -0,0 +1,254 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------ PackageManagement Test -----------------------------------
$InternalGallery = "https://dtlgalleryint.cloudapp.net/api/v2/"
# ------------------------------------------------------------------------------
# Actual Tests:
Describe "find-packageprovider" -Tags @('BVT', 'DRT'){
#make sure the package repository exists
$a=Get-PackageSource -force| select Location, ProviderName
$found = $false
foreach ($item in $a)
{
#name contains "." foo.bar for example for the registered sources internally
if(($item.ProviderName -eq "PowerShellGet") -and ($item.Location -eq $InternalGallery))
{
$found = $true
break
}
}
if(-not $found)
{
# Commented out because powershellget is not fully working yet
# Register-PackageSource -Name 'OneGetTestSource' -Location $InternalGallery -ProviderName 'PowerShellGet' -ForceBootstrap -ErrorAction SilentlyContinue
}
It "find-packageprovider without any parameters, Expect succeed" -Pending {
$a = (Find-PackageProvider -force).name
$a -contains "TSDProvider" | should be $true
}
It "find-packageprovider -name, Expect succeed" -Pending {
$a = (Find-PackageProvider -name nuget).name
$a -contains "GistProvider" | should be $false
}
It "find-packageprovider -name with wildcards, Expect succeed" -Pending {
$a = (Find-PackageProvider -name gist*).name
$a -contains "GistProvider" | should be $true
}
It "find-packageprovider -name with wildcards, Expect succeed" -Pending {
$a = (Find-PackageProvider -name nu*).name
$a -contains "GistProvider" | should be $false
}
It "find-packageprovider -name array, Expect succeed" -Pending {
$names=@("gistprovider", "TSD*")
$a = (Find-PackageProvider -name $names).name
$a -contains "GistProvider" | should be $true
$a -contains "TSDProvider" | should be $true
}
It "find-packageprovider -allversions, Expect succeed" -Pending {
$a = (Find-PackageProvider -allversions)
$a.Name -contains "TSDProvider" | should be $true
$a.Count -ge 1 | should be $true
}
It "find-packageprovider -name -allversions, Expect succeed" -Pending {
$a = (Find-PackageProvider -name TSDProvider -AllVersions).name
$a -contains "TSDProvider" | should be $true
$b = (Find-PackageProvider -name TSDP* -AllVersions).name
$b.Count -ge $a.Count | should be $true
}
It "EXPECTED: success 'find-packageprovider nuget -allVersions'" -Skip {
$a = find-packageprovider -name nuget -allVersions
$a.Count -ge 5| should be $true
$b = find-packageprovider -allVersions
$b.Count -gt $a.Count| should be $true
}
It "find-packageprovider -Source, Expect succeed" -Pending {
$a = (Find-PackageProvider -source $InternalGallery).name
$a -contains "TSDProvider" | should be $true
}
It "find-packageprovider -Source -Name, Expect succeed" -Pending {
$a = (Find-PackageProvider -name gistprovider -source $InternalGallery).name
$a -contains "gistprovider" | should be $true
}
It "find-packageprovider -Name with dependencies, Expect succeed" -Pending {
# gistprovider 1.5 depends on tsdprovider 0.2
$a = (Find-PackageProvider -name gistprovider -RequiredVersion 1.5 -source $InternalGallery -IncludeDependencies)
$a.Name -contains "gistprovider" | should be $true
$a.Name -contains "tsdprovider" | should be $true
}
It "find-install-packageprovider with PowerShell provider, Expect succeed" -Pending {
$provider= find-packageprovider -name TSDProvider -MinimumVersion 0.1 -MaximumVersion 0.2 -Source $InternalGallery
$provider | ?{ $_.Version -eq "0.2" } | should not BeNullOrEmpty
$a=install-packageprovider -name TSDProvider -MinimumVersion 0.1 -MaximumVersion 0.2 -Force -Source $InternalGallery
$a.Name | should match "TSDProvider"
$a.Version | should match "0.2"
}
It "find-install-packageprovider nuget, Expect succeed" -Skip {
$provider= find-packageprovider -name nuget -MinimumVersion 2.8.5.1 -MaximumVersion 2.8.5.123
$provider | ?{ $_.Version -eq "2.8.5.122" } | should not BeNullOrEmpty
$provider.Count -eq 1 | should be $true
$a=install-packageprovider -name nuget -MinimumVersion 2.8.5.1 -MaximumVersion 2.8.5.123 -Force
$a.Name | should match "nuget"
$a.Version | should match "2.8.5.122"
$b= Get-PackageProvider -ListAvailable
$b | ?{ $_.Version -eq "2.8.5.122" } | should not BeNullOrEmpty
}
}
Describe "Find-Package With FilterOnTag" -Tags @('BVT', 'DRT'){
it "EXPECTED: Find a package with FilterOnTag" {
$a=find-package -ProviderName nuget -source $InternalGallery -Name gistprovider -FilterOnTag Provider
$a.name | should match "GistProvider"
}
it "EXPECTED: Find a package with array of FilterOnTags" {
$a=find-package -ProviderName nuget -source $InternalGallery -Name gistprovider -FilterOnTag @('Provider','PackageManagement')
$a.name | should match "GistProvider"
}
it "EXPECTED: Find a package with a bad tag" {
$Error.Clear()
find-package -ProviderName nuget -source $InternalGallery -Name gistprovider -FilterOnTag Pro -ErrorAction SilentlyContinue -ErrorVariable ev
$ev.FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage"
}
it "EXPECTED: Find a package with a bad tag" {
$Error.Clear()
find-package -ProviderName nuget -source $InternalGallery -Name gistprovider -FilterOnTag Providerrrrrr -ErrorAction SilentlyContinue -ErrorVariable ev
$ev.FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage"
}
}
Describe "Find-PackageProvider with Versions" -Tags @('BVT', 'DRT') {
<# Nuget
2.8.5.127
2.8.5.122
2.8.5.120
2.8.5.101
2.8.5.24#>
It "EXPECTED: success 'Find a provider -requiredVersion 3.5'" -Skip {
(find-packageprovider -name Nuget -RequiredVersion 2.8.5.122).Version.ToString() | should match "2.8.5.122"
}
It "EXPECTED: success 'find a provider with MinimumVersion and MaximumVersion'" -Skip {
(find-packageprovider -name nuget -MinimumVersion 2.8.5.105 -MaximumVersion 2.8.5.123).Version.ToString() | should match "2.8.5.122"
}
It "EXPECTED: success 'find a provider with MaximumVersion'" -Skip {
(find-packageprovider -name nuget -MaximumVersion 2.8.5.122).Version -contains "2.8.5.122" | should be $true
}
}
Describe "find-packageprovider Error Cases" -Tags @('BVT', 'DRT') {
AfterAll {
$x =Get-PackageSource -Name OneGetTestSource -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
if($x)
{
Unregister-PackageSource -Name OneGetTestSource
}
}
It "EXPECTED: returns an error when inputing a bad version format" {
$Error.Clear()
find-packageprovider -name Gistprovider -RequiredVersion BOGUSVERSION -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "InvalidVersion,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that does not exist" {
$Error.Clear()
find-packageprovider -name NOT_EXISTS -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MinimumVersion" {
$Error.Clear()
find-packageprovider -name NOT_EXISTS -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MaximumVersion" {
$Error.Clear()
find-packageprovider -name NOT_EXISTS -RequiredVersion 1.0 -MaximumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with a MinimumVersion greater than MaximumVersion" {
$Error.Clear()
find-packageprovider -name nuget -MaximumVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MinimumVersion that does not exist" {
$Error.Clear()
find-packageprovider -name gistprovider -MinimumVersion 20.2 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MaximumVersion that does not exist" {
$Error.Clear()
find-packageprovider -name gistprovider -MaximumVersion 0.1 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that has name with wildcard and version" {
$Error.Clear()
find-packageprovider -name "AnyName*" -RequiredVersion 4.5 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "MultipleNamesWithVersionNotAllowed,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that has name with wildcard and version" {
$Error.Clear()
find-packageprovider -name "AnyName" -RequiredVersion 4.5 -allVersions -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "AllVersionsCannotBeUsedWithOtherVersionParameters,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvider"
}
}
@@ -0,0 +1,82 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------ PackageManagement Test ----------------------------------------------
$nuget = "nuget"
$source = "http://www.nuget.org/api/v2/"
# ------------------------------------------------------------------------------
# Actual Tests:
Describe "Get-package" -Tags @('BVT', 'DRT'){
# make sure that packagemanagement is loaded
It "EXPECTED: Get-package accepts array of strings for -providername parameter" -Skip {
$x = (get-package -providername Programs,Msi)
}
}
Describe "Get-package with version parameter - valid scenarios" -Tags @('BVT', 'DRT'){
$destination = Join-Path $TestDrive GetPackageTests
It "Get-package supports -AllVersions parameter" -Skip {
$outputWithAllVersions = (Get-Package -providername Programs,Msi -AllVersions)
$outputWithoutAllVersions = (Get-Package -providername Programs,Msi)
$outputWithAllVersions.count -ge $outputWithoutAllVersions.count | should be $true
}
It "E2E: Get-package supports -AllVersions parameter for a specific package - with multiple versions from Nuget" {
($foundPackages = Find-Package -Name "adept.nugetrunner" -Provider $nuget -Source $source -AllVersions)
foreach ($package in $foundPackages)
{
($package | Install-Package -Destination $destination -Force)
}
$installedPackages = (Get-Package -Name "adept.nugetrunner" -Provider $nuget -Destination $destination -AllVersions)
$installedPackages.Name | should be "adept.nugetrunner"
$installedPackages.Count -eq $foundPackages.Count | should be $true
# check that getting attributes from meta is not case sensitive
$packageToInspect = $installedPackages[0]
$firstDescr = $packageToInspect.Meta.Attributes["Description"]
# the description should not be null
[string]::IsNullOrWhiteSpace($firstDescr) | should be $false
$secondDescr = $packageToInspect.Meta.Attributes["dEsCriPtIoN"]
# the 2 descriptions should be the same
$firstDescr -eq $secondDescr | should be $true
if (Test-Path $destination\adept.nugetrunner*) {
(Remove-Item -Recurse -Force -Path $destination\adept.nugetrunner*)
}
}
}
Describe "Get-package with version parameter - Error scenarios" -Tags @('BVT', 'DRT'){
It "Get-package -AllVersions -- Cannot be used with other version parameters" {
$Error.Clear()
Get-Package -AllVersions -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "AllVersionsCannotBeUsedWithOtherVersionParameters,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage"
}
It "Get-package -RequiredVersion -- Cannot be used with Min/Max version parameters" {
$Error.Clear()
Get-Package -RequiredVersion 1.0 -MinimumVersion 2.0 -MaximumVersion 3.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackage"
}
}
@@ -0,0 +1,101 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------ PackageManagement Test ----------------------------------------------
# ------------------------------------------------------------------------------
# Actual Tests:
Describe "get-packageprovider" -Tags @('BVT', 'DRT'){
It "lists package providers installed" {
$x = (get-packageprovider -name "nuget").name | should match "nuget"
}
It "lists package providers installed" {
$x = (get-packageprovider -name "nuget" -verbose -Force).name | should match "nuget"
}
It "EXPECTED: Gets The 'Programs' Package Provider" -Skip {
$x = (get-packageprovider -name "Programs").name | should match "Programs"
}
It "EXPECTED: Gets The 'P*' Package Provider" {
$x = (get-packageprovider -name "P*").name.Contains('PowerShellGet')| should be $true
}
It "EXPECTED: returns an error when asking for a provider that does not exist" {
$Error.Clear()
get-packageprovider -name NOT_EXISTS -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider"
}
It "EXPECTED: returns an error when asking for multiple providers that do not exist" {
$Error.Clear()
get-packageprovider -name NOT_EXISTS,NOT_EXISTS2 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider"
}
It "EXPECTED: returns an error when asking for multiple providers that do not exist -list" {
$Error.Clear()
get-packageprovider -name NOT_EXISTS,NOT_EXISTS2 -ListAvailable -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider"
}
It "EXPECTED: returns swidtag conformed object for powershell-based provider" -Skip {
$onegettest = (Get-PackageProvider OneGetTest -ListAvailable | Where-Object {$_.Version.ToString() -eq "9.9.0.0"} | Select -First 1)
$onegettest.Links.Count | should be 3
$found = $false
foreach ($link in $onegettest.Links)
{
if ($link.HRef.ToString() -match "http://oneget.org/icon" -and $link.Relationship -match "icon")
{
$found = $true
}
}
$found | should be $true
}
}
Describe "Get-PackageProvider with list" -Tags @('BVT', 'DRT'){
It "lists package providers installed" {
$x = (Get-PackageProvider).Count -gt 1 | should be $true
$y = (Get-PackageProvider -ListAvailable).Count -gt $x | should be $true
}
It "List two providers" {
(get-packageprovider -name "NuGet" -ListAvailable).name | should match "NuGet"
(get-packageprovider -name "PowerShellGet" -ListAvailable).name | should match "PowerShellGet"
$providers = get-packageprovider -Name NuGet, PowerShellGet -ListAvailable
$providers | ?{ $_.name -eq "NuGet" } | should not BeNullOrEmpty
$providers | ?{ $_.name -eq "PowerShellGet" } | should not BeNullOrEmpty
}
It "List two providers with wildcard chars" {
$providers = get-packageprovider -Name *Get -ListAvailable
$providers | ?{ $_.name -eq "NuGet" } | should not BeNullOrEmpty
# should have both nuget and powershellget
$providers.Count -ge 2 | should be $true
}
}
@@ -0,0 +1,400 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------ PackageManagement Test ----------------------------------------------
#$ProgramModulePath = "$Env:ProgramFiles\WindowsPowerShell\Modules"
$InternalGallery = "https://dtlgalleryint.cloudapp.net/api/v2/"
$InternalSource = 'OneGetTestSource'
<#
SKIP FOR NOW SINCE POWERSHELLGET NOT WORKING YET
make sure the package repository exists
$a=Get-PackageSource -ForceBootstrap| select Name, Location, ProviderName
$found = $false
foreach ($item in $a)
{
#name contains "." foo.bar for example for the registered sources internally
if($item.ProviderName -eq "PowerShellGet")
{
if ($item.Location -eq $InternalGallery) {
Unregister-PackageSource $item.Name -Provider "PowerShellGet" -ErrorAction SilentlyContinue
}
}
}
Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ForceBootstrap -ErrorAction SilentlyContinue
#>
# ------------------------------------------------------------------------------
# Actual Tests:
Describe "import-packageprovider" -Tags @('BVT', 'DRT'){
It "Import -force 'PowerShellGet', a builtin package provider, Expect succeed" {
#avoid popup for installing nuget-any.exe
Find-PackageProvider -force
(Import-PackageProvider 'PowerShellGet' -verbose -force).name | should match "PowerShellGet"
}
It "Import a PowerShell package provider Expect succeed" -Skip {
(get-packageprovider -name "OneGetTest" -list).name | should match "OneGetTest"
$x = PowerShell '(Import-PackageProvider OneGetTest -WarningAction SilentlyContinue).Name'
$x | should match "OneGetTest"
$x = PowerShell '(Import-PackageProvider OneGetTest -WarningAction SilentlyContinue -force).Name'
$x | should match "OneGetTest"
}
It "Import 'OneGetTestProvider' CSharp package provider with filePath from programs folder, Expect succeed" -Skip {
$path = "$($ProgramProviderInstalledPath)\Microsoft.PackageManagement.OneGetTestProvider.dll"
$path | should Exist
$job=Start-Job -ScriptBlock {
param($path) import-packageprovider -name $path;
} -ArgumentList @($path)
$a= $job | Receive-Job -Wait
$a.Name | should match "OneGetTestProvider"
}
It "Import 'PSChained1Provider' PowerShell package provider with filePath from programfiles folder, Expect succeed" -Skip {
$path = "$($ProgramModulePath)\PSChained1Provider.psm1"
$path | should Exist
$job=Start-Job -ScriptBlock {
param($path) import-packageprovider -name $path;
} -ArgumentList @($path)
$a= $job | Receive-Job -Wait
$a.Name | should match "PSChained1Provider"
}
It "Import a CSharp package provider with filePath from user folder -force, Expect succeed" -Skip {
$path = "$($UserProviderInstalledPath)\Microsoft.PackageManagement.OneGetTestProvider.dll"
$path | should Exist
$job=Start-Job -ScriptBlock {
param($path) import-packageprovider -name $path;
} -ArgumentList @($path)
$a= $job | Receive-Job -Wait
$a.Name | should match "OneGetTestProvider"
}
It "Import a PowerShell package provider with filePath from user folder -force, Expect succeed" -Skip {
$path = "$($UserModuleFolder)\PSChained1Provider.psm1"
$path | should Exist
$job=Start-Job -ScriptBlock {
param($path) import-packageprovider -name $path;
} -ArgumentList @($path)
$a= $job | Receive-Job -Wait
$a.Name | should match "PSChained1Provider"
}
It "Import a PowerShell package provider with -force, Expect succeed" -Skip {
$path = "$($UserModuleFolder)\PSChained1Provider.psm1"
$path | should Exist
$newPath = "$($UserModuleFolder)\MyTest.psm1"
Copy-Item -Path $path -Destination $newPath -Force
$job=Start-Job -ScriptBlock {
param($newPath) import-packageprovider -name $newPath -Force;
} -ArgumentList @($newPath)
$a= $job | Receive-Job -Wait
$a.Name | should match "PSChained1Provider"
$job=Start-Job -ScriptBlock {
param($newPath)
import-packageprovider -name $newPath -Force
Set-Content -Path $newPath -Value "#test" -force
import-packageprovider -name $newPath -Force
} -ArgumentList @($newPath)
Receive-Job -Wait -Job $job -ErrorVariable theError 2>&1
$theError.FullyQualifiedErrorId | should be "FailedToImportProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "Import 'OneGetTest' PowerShell package provider that has multiple versions, Expect succeed" -Skip {
#check all version of OneGetTest is listed
$x = get-packageprovider "OneGetTest" -ListAvailable
$x | ?{ $_.Version.ToString() -eq "9.9.0.0" } | should not BeNullOrEmpty
$x | ?{ $_.Version.ToString() -eq "3.5.0.0" } | should not BeNullOrEmpty
$x | ?{ $_.Version.ToString() -eq "1.1.0.0" } | should not BeNullOrEmpty
#latest one is imported
$y = powershell '(import-packageprovider -name "OneGetTest").Version.Tostring()'
$y | should match "9.9.0.0"
}
}
Describe "import-packageprovider Error Cases" -Tags @('BVT', 'DRT'){
It "Expected error when importing wildcard chars 'OneGetTest*" {
$Error.Clear()
import-packageprovider -name OneGetTest* -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "InvalidParameter,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when inputing a bad version format" {
$Error.Clear()
import-packageprovider -name Gistprovider -RequiredVersion BOGUSVERSION -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "InvalidVersion,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that does not exist" {
$Error.Clear()
import-packageprovider -name NOT_EXISTS -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with file full path and version" -Skip {
$Error.Clear()
import-packageprovider -name "$($ProgramModulePath)\PSChained1Provider.psm1" -RequiredVersion 9.9.9 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "FullProviderFilePathVersionNotAllowed,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MinimumVersion" {
$Error.Clear()
import-packageprovider -name PowerShellGet -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MaximumVersion" {
$Error.Clear()
import-packageprovider -name PowerShellGet -RequiredVersion 1.0 -MaximumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with a MinimumVersion greater than MaximumVersion" {
$Error.Clear()
import-packageprovider -name PowerShellGet -MaximumVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "MinimumVersionMustBeLessThanMaximumVersion,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MinimumVersion that does not exist" {
$Error.Clear()
Import-packageprovider -name OneGetTest -MinimumVersion 20.2 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MaximumVersion that does not exist" {
$Error.Clear()
Import-packageprovider -name OneGetTest -MaximumVersion 0.2 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that has name with wildcard and version" {
$Error.Clear()
Import-packageprovider -name "OneGetTest*" -RequiredVersion 4.5 -force -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "MultipleNamesWithVersionNotAllowed,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider"
}
}
Describe "Import-PackageProvider with OneGetTest that has 3 versions: 1.1, 3.5, and 9.9." -Tags @('BVT', 'DRT') {
It "EXPECTED: success 'import OneGetTest -requiredVersion 3.5'" -Skip {
powershell '(Import-packageprovider -name OneGetTest -requiredVersion 3.5 -WarningAction SilentlyContinue).Version.ToString()' | should match "3.5.0.0"
# test that if we call a function with error, powershell does not hang for the provider
$warningMsg = powershell '(Import-packageprovider -name OneGetTest -requiredVersion 3.5) | Out-Null; Get-Package -ProviderName OneGetTest 3>&1'
$result = $warningMsg[0]
if ($PSCulture -eq "en-US") {
foreach($w in $warningMsg)
{
if($w -match 'WARNING: Cannot bind parameter')
{
$result = $w
}
}
$result.StartsWith('WARNING: Cannot bind parameter') | should be $true
}
}
It "EXPECTED: success 'Import OneGetTest -requiredVersion 3.5 and then 9.9 -force'" -Skip {
$a = powershell {(Import-packageprovider -name OneGetTest -RequiredVersion 3.5) > $null; (Import-packageprovider -name OneGetTest -requiredVersion 9.9 -force)}
$a.Version.ToString()| should match "9.9.0.0"
}
It "EXPECTED: success 'import OneGetTest with MinimumVersion and MaximumVersion'" -Skip {
powershell '(Import-packageprovider -name OneGetTest -MinimumVersion 1.2 -MaximumVersion 5.0 -WarningAction SilentlyContinue).Version.ToString()' | should match "3.5.0.0"
}
It "EXPECTED: success 'OneGetTest with MaximumVersion'" -Skip {
powershell '(Import-packageprovider -name OneGetTest -MaximumVersion 3.5 -WarningAction SilentlyContinue).Version.ToString()' | should match "3.5.0.0"
}
It "EXPECTED: success 'OneGetTest with MinimumVersion'" -Skip {
powershell '(Import-packageprovider -name OneGetTest -MinimumVersion 2.2 -WarningAction SilentlyContinue).Version.ToString()' | should match "9.9.0.0"
}
It "EXPECTED: success 'OneGetTest Find-Package with Progress'" -Skip {
$ps = [PowerShell]::Create()
$ps.AddScript("Import-PackageProvider -Name OneGetTest -RequiredVersion 9.9; Find-Package -ProviderName OneGetTest")
$ps.Invoke()
$ps.Streams.Progress.Count | Should be 29
$culture = (Get-Culture).Name
if ($culture -eq "en-us") {
$ps.Streams.Progress[1].Activity | Should match "Starting some progress"
$ps.Streams.Progress[1].StatusDescription | should match "Processing"
$ps.Streams.Progress[1].CurrentOperation | should match "Starting"
$ps.Streams.Progress[5].Activity | should match "Updating"
$ps.Streams.Progress[5].StatusDescription | should match "Finding packages"
$ps.Streams.Progress[6].Activity | should match "Updating Inner"
$ps.Streams.Progress[6].StatusDescription | should match "Finding inner packages"
$ps.Streams.Progress[7].Activity | should match "Updating Inner"
}
$ps.Streams.Progress[1].ActivityId | Should Be 0
$ps.Streams.Progress[1].ParentActivityId | should be -1
$ps.Streams.Progress[1].SecondsRemaining | should match 10
$ps.Streams.Progress[1].RecordType -eq [System.Management.Automation.ProgressRecordType]::Processing | should be true
$ps.Streams.Progress[1].PercentComplete | should be 22
$ps.Streams.Progress[2].SecondsRemaining | should be 5
$ps.Streams.Progress[4].PercentComplete | should be 100
$ps.Streams.Progress[4].RecordType -eq [System.Management.Automation.ProgressRecordType]::Completed | should be true
$ps.Streams.Progress[5].PercentComplete | should be 0
$ps.Streams.Progress[6].PercentComplete | should be 0
$ps.Streams.Progress[7].PercentComplete | should be 25
}
It "EXPECTED: success 'OneGetTest Find-Package returns correct TagId'" -Skip {
$ps = [PowerShell]::Create()
$ps.AddScript("Import-PackageProvider -Name OneGetTest -RequiredVersion 9.9; Find-Package -ProviderName OneGetTest")
$result = $ps.Invoke() | Select -First 1
$result.TagId | should match "MyVeryUniqueTagId"
}
It "EXPECTED: success 'OneGetTest Get-Package returns correct package object using swidtag'" -Skip {
$ps = [PowerShell]::Create()
$null = $ps.AddScript("`$null = Import-PackageProvider -Name OneGetTest -RequiredVersion 9.9; Get-Package -ProviderName OneGetTest")
$result = $ps.Invoke()
$result.Count | should Be 2
($result | Select -Last 1).TagId | should match "jWhat-jWhere-jWho-jQuery"
}
It "EXPECTED: success 'OneGetTest Get-Package returns correct progress message'" -Skip {
$ps = [PowerShell]::Create()
$null = $ps.AddScript("`$null = Import-PackageProvider -Name OneGetTest -RequiredVersion 9.9; Get-Package -ProviderName OneGetTest")
$result = $ps.Invoke()
$ps.Streams.Progress[1].PercentComplete | should be 0
$ps.Streams.Progress[1].Activity | should match "Updating"
$ps.Streams.Progress[1].ActivityId | should be 10
$ps.Streams.Progress[2].PercentComplete | should be 0
$ps.Streams.Progress[2].Activity | should match "Updating Inner"
$ps.Streams.Progress[2].ParentActivityId | should be 10
$ps.Streams.Progress[3].PercentComplete | should be 25
$ps.Streams.Progress[3].Activity | should match "Updating Inner"
$ps.Streams.Progress[3].ParentActivityId | should be 10
}
}
Describe "Import-PackageProvider with OneGetTestProvider that has 2 versions: 4.5, 6.1" -Tags @('BVT', 'DRT') {
# install onegettestprovider
# Not working yet since powershellget not working
# Install-PackageProvider -Name OneGetTestProvider -RequiredVersion 4.5.0.0 -Source $InternalGallery
# Install-PackageProvider -Name OneGetTestProvider -RequiredVersion 6.1.0.0 -Source $InternalGallery
It "EXPECTED: Get-PackageProvider -ListAvailable succeeds" -Pending {
$providers = Get-PackageProvider -ListAvailable
($providers | Where-Object {$_.Name -eq 'OneGetTest'}).Count | should match 3
($providers | Where-Object {$_.Name -eq 'OneGetTestProvider'}).Count -ge 2 | should be $true
}
It "EXPECTED: Get-PackageProvider -ListAvailable succeeds even after importing gist provider" -Pending {
Install-PackageProvider GistProvider -Source $InternalGallery
Import-PackageProvider Gist
$providers = Get-PackageProvider -ListAvailable
($providers | Where-Object {$_.Name -eq 'OneGetTest'}).Count | should match 3
($providers | Where-Object {$_.Name -eq 'OneGetTestProvider'}).Count -ge 2 | should be $true
}
It "EXPECTED: success 'import OneGetTestProvider -requiredVersion 4.5'" -Pending {
Import-PackageProvider -Name OneGetTestProvider -RequiredVersion 4.5 -Force
(Get-PackageProvider OneGetTestProvider).Version.ToString() | should match '4.5.0.0'
}
It "EXPECTED: success 'import OneGetTestProvider with MinimumVersion and MaximumVersion'" -Pending {
Import-packageprovider -name OneGetTestProvider -MinimumVersion 4.6 -MaximumVersion 6.2 -Force
(Get-PackageProvider OneGetTestProvider).Version.ToString() | should match '6.1.0.0'
}
It "EXPECTED: success 'import OneGetTestProvider with MaximumVersion'" -Pending {
Import-packageprovider -name OneGetTestProvider -MaximumVersion 4.6 -Force
(Get-PackageProvider OneGetTestProvider).Version.ToString() | should match '4.5.0.0'
}
It "EXPECTED: success 'OneGetTestProvider with MinimumVersion'" -Pending {
Import-packageprovider -name OneGetTestProvider -MinimumVersion 6.0.5 -Force
(Get-PackageProvider OneGetTestProvider).Version -ge [version]'6.1.0.0' | should be $true
}
It "EXPECTED: success 'Import OneGetTestProvider -requiredVersion 4.5 and then 6.1 -force'" -Pending {
Import-PackageProvider -Name OneGetTestProvider -RequiredVersion 4.5 -Force;
Import-PackageProvider -Name OneGetTestProvider -RequiredVersion 6.1 -Force;
(Get-PackageProvider OneGetTestProvider).Version.ToString() | should match '6.1.0.0'
}
It "EXPECTED: success 'Import OneGetTestProvider -MinimumVersion 4.5 and then MaximumVersion 5.0 -force'" -Pending {
Import-PackageProvider -Name OneGetTestProvider -MinimumVersion 4.5 -Force;
(Get-PackageProvider OneGetTestProvider).Version -ge [version]'6.1.0.0' | should be $true
Import-PackageProvider -Name OneGetTestProvider -MaximumVersion 5.0 -Force;
(Get-PackageProvider OneGetTestProvider).Version.ToString() | should match '4.5.0.0'
}
}
@@ -0,0 +1,779 @@
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# ------------------ PackageManagement Test -----------------------------------
$InternalGallery = "https://dtlgalleryint.cloudapp.net/api/v2/"
$InternalGallery2 = "http://dtlgalleryint.cloudapp.net/api/v2/"
$InternalSource = 'OneGetTestSource'
$InternalSource2 = 'OneGetTestSource2'
$ProviderFolder = "$env:ProgramFiles\PackageManagement\ProviderAssemblies"
#make sure the package repository exists
<# Cannot run these yet since powershellget not working yet
$a=Get-PackageSource -ForceBootstrap| select Name, Location, ProviderName
$found = $false
foreach ($item in $a)
{
#name contains "." foo.bar for example for the registered sources internally
if($item.ProviderName -eq "PowerShellGet")
{
if (($item.Location -eq $InternalGallery) -or ($item.Location -eq $InternalGallery2)) {
Unregister-PackageSource $item.Name -Provider "PowerShellGet" -ErrorAction SilentlyContinue
}
}
}
Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ForceBootstrap -ErrorAction SilentlyContinue
Register-PackageSource -Name $InternalSource2 -Location $InternalGallery2 -ProviderName 'PowerShellGet' -ForceBootstrap -ErrorAction SilentlyContinue
#>
# ------------------------------------------------------------------------------
# Actual Tests:
Describe "install-packageprovider" -Tags @('BVT', 'DRT') {
<#
BeforeEach {
$m= Get-InstalledModule -Name myalbum -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
if($m -and $m.InstalledLocation)
{
Remove-Item -Path $m.InstalledLocation -Recurse -force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -Verbose
}
}
#>
It "install-packageprovider, Expect succeed" -Pending {
$a = (install-PackageProvider -name gistprovider -force -source $InternalSource).name
$a -contains "gistprovider" | should be $true "gistprovider"
# check for swidtag field
$gist = (Get-PackageProvider gist -ListAvailable | Select -First 1)
$gist.Entities.Count | should be 2
$found = $false
foreach ($entity in $gist.Entities)
{
if ($entity.Name -match "Doug Finke" -and $entity.Role -match "author")
{
$found = $true
}
}
$found | should be $true
$gist.VersionScheme | should match "MultiPartNumeric"
}
It "install-packageprovider from bootstrap web site, Expect succeed" -Skip {
$a = (Install-PackageProvider -Name nuget -RequiredVersion 2.8.5.127 -Force).name
$a | should match "nuget"
# check for swidtag field
$nugetBootstrapped = (Get-PackageProvider -Name nuget -ListAvailable | Where-Object {$_.Version.ToString() -eq "2.8.5.127"} | Select-Object -First 1)
$nugetBootstrapped.Links[0].HRef.ToString() | should match "https://oneget.org/nuget-anycpu-2.8.5.127.exe"
$nugetBootstrapped.Links[0].Relationship | should match "installationmedia"
}
It "find | install-packageprovider -name array, Expect succeed" -Pending {
$names=@("gistprovider", "TSDProvider")
#
$a = (find-PackageProvider -name $names -Source $InternalSource | Install-PackageProvider -force).name
$a -contains "GistProvider" | should be $true
$a -contains "TSDProvider" | should be $true
}
It "find | install-packageprovider nuget should imported and installed, Expect succeed" -Skip {
$a = Find-PackageProvider -name NuGet -RequiredVersion 2.8.5.202 | install-PackageProvider -force
$a.Name | Should match "NuGet"
$a.Version | Should match "2.8.5.202"
}
It "find | install-packageprovider nuget should imported and installed, Expect succeed" -Skip {
$a = install-PackageProvider -name NuGet -force
$a | ?{ $_.name -eq "NuGet" } | should not BeNullOrEmpty
$a | ?{ $_.Version -gt "2.8.5.202" } | should not BeNullOrEmpty
}
It "install-packageprovider myalbum should imported and installed, Expect succeed" -Pending {
$a = Install-PackageProvider -name MyAlbum -Source $InternalSource -force
$a | ?{ $_.name -eq "MyAlbum" } | should not BeNullOrEmpty
}
It "find | install-packageprovider myalbum should imported and installed, Expect succeed" -Pending {
$a = Find-PackageProvider -name MyAlbum -Source $InternalSource -RequiredVersion 0.1.2 | install-PackageProvider -force
$a | ?{ $_.name -eq "MyAlbum" } | should not BeNullOrEmpty
$a | ?{ $_.Version -eq "0.1.2" } | should not BeNullOrEmpty
}
}
<# Don't need this test since we are not boostraping
Describe "install-packageprovider with local source" -Tags @('BVT', 'DRT') {
BeforeAll{
if( test-path $destination ) {
rmdir -recurse -force $destination -ea silentlycontinue
}
mkdir $destination -ea silentlycontinue
$nugetprovider = (install-PackageProvider -name nuget -force -RequiredVersion 2.8.5.201).name
$nugetprovider -contains "nuget" | should be $true "nuget"
$nugetprovider = (install-PackageProvider -name nuget -force -RequiredVersion 2.8.5.202).name
$nugetprovider -contains "nuget" | should be $true "nuget"
# setup the test folder
mkdir $destination\2.8.5.202 -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
mkdir $destination\2.8.5.201 -Force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
Get-ChildItem "$ProviderFolder\Nuget\2.8.5.202" -Recurse | Copy-Item -Destination $destination\2.8.5.202\Microsoft.PackageManagement.NuGetProvider.dll -Force -Verbose
Get-ChildItem "$ProviderFolder\Nuget\2.8.5.201" -Recurse | Copy-Item -Destination $destination\2.8.5.201\Microsoft.PackageManagement.NuGetProvider.dll -Force -Verbose
Get-ChildItem "$Env:ProgramFiles\WindowsPowerShell\Modules\Microsoft.PackageManagement.Test.dll" | Copy-Item -Destination $destination -Force -verbose
}
AfterAll{
if( test-path $destination ) {
rmdir -recurse -force $destination -ea silentlycontinue
}
$testprovider = "$ProviderFolder\Test Providers for OneGet"
if( test-path $testprovider ) {
rmdir -recurse -force $testprovider -ea silentlycontinue
}
#make sure we are using the latest Nuget provider
Install-PackageProvider -name nuget -force
}
It "Find-packageprovider -source filefolder, Expect succeed" {
$a= (Find-PackageProvider -source $destination).Name
$a -like "nuget*" | should be $true
$a -like "Test Providers for OneGet" | should be $true
}
It "Find-packageprovider -source filefolder -name, Expect the latest version returned" {
$a= Find-PackageProvider -source $destination -name nuget*
$a.Name -like "nuget*" | should match $true
$a.Version | should match "2.8.5.202"
}
It "Find-packageprovider -source filefolder -name -allversions, Expect All versions returned" {
$a= Find-PackageProvider -source $destination -name nuget* -AllVersions
# all versions returned
$a | ?{$_.version -eq "2.8.5.202" } | should not BeNullOrEmpty
$a | ?{$_.version -eq "2.8.5.201" } | should not BeNullOrEmpty
}
It "Find-packageprovider -source file, Expect succeed" {
$a= (Find-PackageProvider -source "$destination\Microsoft.PackageManagement.Test.dll").Name
$a -like "nuget" | should not be $true
$a -contains "Test Providers for OneGet" | should be $true
}
It "Install-packageprovider -source file, Expect succeed" {
$a= (Install-PackageProvider -source "$destination\Microsoft.PackageManagement.Test.dll" -name "Test Providers for OneGet" -force).Name
$a -eq "Test Providers for OneGet" | should be $true
}
It "install-PackageProvider -source folder, Expect succeed" {
$a= (Install-PackageProvider -force -source $destination -name "Test Providers for OneGet")
$a.Name -eq "Test Providers for OneGet" | should be $true
}
It "Find-packageprovider and install-PackageProvider, Expect succeed" {
$a= (find-PackageProvider -Name "Test Providers for OneGet" -Source $destination | Install-PackageProvider -force)
$a.Name -contains "Test Providers for OneGet" | should be $true
}
It "Find and Install PackageProvider with version, Expect succeed" {
$a= install-PackageProvider -Name nugetprovider -Source $destination -RequiredVersion 2.8.5.201 -verbose -force
$a.Name -like "nuget*" | should be $true
$a.Version | should match "2.8.5.201"
}
}
#>
Describe "Install-Save-Package with multiple sources" -Tags @('BVT', 'DRT'){
$destination = Join-Path $TestDrive "installpp"
It "install-package with array of registered sources with a single provider, Expect succeed" -Pending {
#powershellget is the provider selected
$x= install-package TSDProvider -force -Source @($InternalSource, $InternalSource2)
$x | ?{ $_.name -eq "TSDProvider" } | should not BeNullOrEmpty
$y= install-package TSDProvider -force -Source @($InternalGallery, $InternalGallery2) -ProviderName nuget
$y | ?{ $_.name -eq "TSDProvider" } | should not BeNullOrEmpty
}
It "install-package with array of sources, Expect succeed" {
$x= install-package jquery -force -Source @('foooobarrrr', 'https://www.nuget.org/api/v2') -ProviderName @('PowershellGet', 'NuGet')
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
#$x | ?{ $_.Source -eq "https://www.nuget.org/api/v2" } | should not BeNullOrEmpty
}
It "install-save-package matches with multiple providers with single source, Expect succeed" -Pending {
try
{
Register-PackageSource -Name foo -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue
Register-PackageSource -Name bar -Location $InternalGallery -ProviderName 'NuGet' -ErrorAction SilentlyContinue
if (test-path "$destination") {
rm $destination -force -Recurse
}
$x= install-package tsdprovider -force -Source $InternalGallery -ProviderName @('NuGet', 'PowershellGet')
$x | ?{ $_.name -eq "tsdprovider" } | should not BeNullOrEmpty
$x | ?{ $_.Source -eq "bar" } | should not BeNullOrEmpty
$x | ?{ $_.Providername -eq "NuGet" } | should not BeNullOrEmpty
$y= save-package tsdprovider -force -Source $InternalGallery -ProviderName @('NuGet', 'PowershellGet') -path $destination
$y | ?{ $_.name -eq "tsdprovider" } | should not BeNullOrEmpty
$y | ?{ $_.Source -eq "bar" } | should not BeNullOrEmpty
$y | ?{ $_.Providername -eq "NuGet" } | should not BeNullOrEmpty
(test-path "$destination\TSDProvider*") | should be $true
if (test-path "$destination\TSDProvider*") {
rm $destination\TSDProvider* -force -Recurse
}
}
finally
{
UnRegister-PackageSource -Name foo -ErrorAction SilentlyContinue
UnRegister-PackageSource -Name bar -ErrorAction SilentlyContinue
}
}
It "install-save-package does not match with any providers with single source, Expect fail" -Pending {
try
{
Register-PackageSource -Name foo -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue
Register-PackageSource -Name bar -Location $InternalGallery -ProviderName 'NuGet' -ErrorAction SilentlyContinue
$Error.Clear()
$x= install-package jquery -force -Source $InternalGallery -ProviderName @('NuGet', 'PowershellGet') -ErrorVariable theError -ErrorAction SilentlyContinue
$theError.FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage"
$Error.Clear()
$y= save-package jquery -force -Source $InternalGallery -ProviderName @('NuGet', 'PowershellGet') -path $destination -ErrorVariable theError -ErrorAction SilentlyContinue
$theError.FullyQualifiedErrorId | should be "NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage"
}
finally
{
UnRegister-PackageSource -Name foo -ErrorAction SilentlyContinue
UnRegister-PackageSource -Name bar -ErrorAction SilentlyContinue
}
}
It "install-save-package when the multiple providers find a package but no providers specified, Expect fail" -Pending {
try
{
Register-PackageSource -Name foo -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ErrorAction SilentlyContinue
Register-PackageSource -Name bar -Location $InternalGallery -ProviderName 'NuGet' -ErrorAction SilentlyContinue
$Error.Clear()
$x= install-package tsdprovider -force -Source @($InternalGallery) -ErrorVariable theError -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$theError.FullyQualifiedErrorId | should be "DisambiguateForInstall,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage"
$Error.Clear()
$y= save-package tsdprovider -force -Source @($InternalGallery) -path $destination -ErrorVariable theError -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
$theError.FullyQualifiedErrorId | should be "DisambiguateForInstall,Microsoft.PowerShell.PackageManagement.Cmdlets.SavePackage"
}
finally
{
UnRegister-PackageSource -Name foo -ErrorAction SilentlyContinue
UnRegister-PackageSource -Name bar -ErrorAction SilentlyContinue
}
}
# Skip as we don't have chocolatey anymore
It "install-save-package with multiple names, providers, Expect succeed" -Skip {
try {
Register-PackageSource -Name foobar -Location http://www.nuget.org/api/v2 -ProviderName 'NuGet' -ErrorAction SilentlyContinue
if (test-path "$destination") {
rm $destination -force -Recurse
}
$x= install-package -name @('Bootstrap', 'jquery') -force -ProviderName @('NuGet', 'Chocolatey')
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
$x | ?{ $_.name -eq "Bootstrap" } | should not BeNullOrEmpty
$y= save-package -name 'jquery' -force -ProviderName @('NuGet', 'Chocolatey') -path $destination
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
(test-path "$destination\jquery*") | should be $true
if (test-path "$destination\jquery*") {
rm $destination\jquery* -force -Recurse
}
}
finally
{
UnRegister-PackageSource -Name foobar -ErrorAction SilentlyContinue
}
}
# Skip as no chocolatey
It "install-save-package with multiple names, providers and sources, Expect succeed" -Skip {
# Contoso and Contososerver can be found from $InternalGallery - No ambiguity.
# Jquery can be found by the NuGet from both source locations provided.
if (test-path "$destination") {
rm $destination -force -Recurse
}
$x= install-package -name @('Contoso', 'jquery', 'ContosoServer') -force -Source @($InternalGallery, 'http://www.nuget.org/api/v2', 'https://www.nuget.org/api/v2') -ProviderName @('NuGet', 'Chocolatey')
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
$x | ?{ $_.name -eq "Contoso" } | should not BeNullOrEmpty
$x | ?{ $_.name -eq "ContosoServer" } | should not BeNullOrEmpty
$y= save-package -name @('Contoso', 'jquery', 'ContosoServer') -force -Source @($InternalGallery,'http://www.nuget.org/api/v2','https://www.nuget.org/api/v2') -ProviderName @('NuGet', 'Chocolatey') -path $destination
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
$x | ?{ $_.name -eq "Contoso" } | should not BeNullOrEmpty
$x | ?{ $_.name -eq "ContosoServer" } | should not BeNullOrEmpty
(test-path "$destination\Contoso*") | should be $true
if (test-path "$destination\Contoso*") {
rm $destination\Contoso* -force -Recurse
}
}
It "save-package with array of registered sources, Expect succeed" -Pending {
if (test-path "$destination") {
rm $destination -force -Recurse
}
$x= save-package TSDProvider -force -Source @($InternalSource, $InternalSource2) -path $destination -ProviderName @('PowershellGet', 'NuGet')
$x | ?{ $_.name -eq "TSDProvider" } | should not BeNullOrEmpty
(test-path "$destination\TSDProvider*") | should be $true
if (test-path "$destination\TSDProvider*") {
rm $destination\TSDProvider* -force -Recurse
}
}
It "save-package with array of sources, Expect succeed" -Skip {
if (test-path "$destination") {
rm $destination -force -Recurse
}
$x= save-package jquery -force -Source @('fffffbbbbb', 'https://www.nuget.org/api/v2') -path $destination -ProviderName @('Nuget', 'Chocolatey')
$x | ?{ $_.name -eq "jquery" } | should not BeNullOrEmpty
$x | ?{ $_.Source -eq "https://www.nuget.org/api/v2" } | should not BeNullOrEmpty
(test-path "$destination\jquery*") | should be $true
if (test-path "$destination\jquery*") {
rm $destination\jquery* -force -Recurse
}
}
}
Describe "install-packageprovider with Whatif" -Tags @('BVT', 'DRT'){
# make sure that packagemanagement is loaded
#import-packagemanagement
BeforeEach{
$tempFile = [System.IO.Path]::GetTempFileName()
$whatif = "What if: Performing the operation";
}
AfterEach {
if(Test-Path $tempFile)
{
Remove-Item $tempFile -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
}
}
It "install-packageprovider -name nuget with whatif, Expect succeed" -Skip {
if($PSCulture -eq 'en-US'){
# Start Transcript
Start-Transcript -Path $tempFile
install-PackageProvider -name nuget -force -warningaction:silentlycontinue -ErrorAction SilentlyContinue -whatif
# Stop Transcript and get content of transcript file
Stop-Transcript
$transcriptContent = Get-Content $tempFile
$transcriptContent | where { $_.Contains( $whatif ) } | should be $true
Remove-Item $whatif -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
}
}
It "install-packageprovider -name gistprovider with whatif, Expect succeed" -Pending {
if($PSCulture -eq 'en-US'){
# Start Transcript
Start-Transcript -Path $tempFile
install-PackageProvider -name gistprovider -force -source $InternalGallery -warningaction:silentlycontinue -ErrorAction SilentlyContinue -whatif
# Stop Transcript and get content of transcript file
Stop-Transcript
$transcriptContent = Get-Content $tempFile
$transcriptContent | where { $_.Contains( $whatif ) } | should be $true
Remove-Item $whatif -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
}
}
}
Describe "install-packageprovider with Scope" -Tags @('BVT', 'DRT'){
# PENDING a lot of these tests because jobs are broken on OPS
BeforeAll {
if ($IsWindows)
{
$userName = "smartguy"
$password = "password%1"
#net user $userName /delete | Out-Null
net user $userName $password /add
$secesurestring = ConvertTo-SecureString $password -AsPlainText -Force
$credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $secesurestring
}
}
AfterEach {
$m= Get-InstalledModule -Name tsdprovider -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
if($m -and $m.InstalledLocation)
{
Remove-Item -Path $m.InstalledLocation -Recurse -force -ErrorAction SilentlyContinue -WarningAction SilentlyContinue -Verbose
}
}
It "install-packageprovider without scope in a non-admin console, expect fail" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock { Install-PackageProvider -Name gistprovider -force -requiredVersion 2.8.5.127} -Credential $credential
Receive-Job -Wait -Job $job -ErrorVariable theError 2>&1
$theError.FullyQualifiedErrorId | should be "InstallRequiresCurrentUserScopeParameterForNonAdminUser,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "install-packageprovider without scope in a non-admin console, expect fail" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock { Install-PackageProvider -Name gistprovider -force } -Credential $credential
Receive-Job -Wait -Job $job -ErrorVariable theError 2>&1
$theError.FullyQualifiedErrorId | should be "InstallRequiresCurrentUserScopeParameterForNonAdminUser,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "install-packageprovider with AllUsers scope in a non-admin console, expect fail" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock { Install-PackageProvider -Name gistprovider -force -scope AllUsers} -Credential $credential
Receive-Job -Wait -Job $job -ErrorVariable theError2 2>&1
$theError2.FullyQualifiedErrorId | should be "InstallRequiresCurrentUserScopeParameterForNonAdminUser,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "install-packageprovider CurrentUser scope in a non-admin console, expect succeed" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock {
$source="testsource"
$x =Get-PackageSource -Name $source -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
if ($x)
{
Write-Verbose "exist $source"
}
else
{
Write-Verbose "'$source' does not exist. Registering it"
$InternalGallery = "https://dtlgalleryint.cloudapp.net/api/v2/"
Register-PackageSource -Name $source -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ForceBootstrap -ErrorAction SilentlyContinue
}
Install-PackageProvider -Name tsdprovider -force -scope CurrentUser -source $source
} -Credential $credential
$a= Receive-Job -Wait -Job $job
$a | ?{ $_.name -eq "tsdprovider" } | should not BeNullOrEmpty
}
It "find and install-packageprovider without scope in a non-admin console, expect fail" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock { Find-PackageProvider -Name gistprovider | Install-PackageProvider -force} -Credential $credential
Receive-Job -Wait -Job $job -ErrorVariable theError3 2>&1
$theError3.FullyQualifiedErrorId | should be "InstallRequiresCurrentUserScopeParameterForNonAdminUser,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "find and install-packageprovider CurrentUser scope in a non-admin console, expect succeed" -Pending {
$Error.Clear()
$job=Start-Job -ScriptBlock { Find-PackageProvider -Name tsdprovider | Install-PackageProvider -force -scope CurrentUser} -Credential $credential
$a= Receive-Job -Wait -Job $job
$a | ?{ $_.name -eq "tsdprovider" } | should not BeNullOrEmpty
}
}
Describe "install-PackageProvider with Versions" -Tags @('BVT', 'DRT') {
# make sure that packagemanagement is loaded
<# Nuget
2.8.5.127
2.8.5.122
2.8.5.120
2.8.5.101
2.8.5.24#>
It "EXPECTED: success 'install, import, and get nuget package provider'" -Pending {
# Have to change from using nuget to gist when we enable this test
(install-packageprovider -name Nuget -requiredVersion 2.8.5.122 -force).Version.ToString() | should match "2.8.5.122"
$x = powershell {(import-packageprovider -name nuget -requiredVersion 2.8.5.122 -force > $null); get-packageprovider -name nuget}
$x.Name | should match "Nuget"
$x | ?{ $_.Version.ToString() -eq "2.8.5.122" } | should not BeNullOrEmpty
}
It "Install, import, and get a powershell package provider-required version" -Pending {
$a = (install-PackageProvider -name gistprovider -force -requiredversion 1.5 -source $InternalSource)
$a.Name -contains "gistprovider" | should be $true
$a.Version -contains "1.5" | should be $true
$x = powershell {(import-packageprovider -name gist -requiredVersion 1.5 -force > $null); get-packageprovider -name gist -list}
$x | ?{ $_.name -eq "Gist" } | should not BeNullOrEmpty
$x | ?{ $_.Version.ToString() -eq "1.5.0.0" } | should not BeNullOrEmpty
}
It "EXPECTED: success 'install a provider with MinimumVersion and MaximumVersion'" -Pending {
# Have to change from using nuget to gist when we enable this test
(install-packageprovider -name nuget -MinimumVersion 2.8.5.101 -MaximumVersion 2.8.5.123 -force).Version.ToString() | should match "2.8.5.122"
}
It "EXPECTED: success 'install a provider with MaximumVersion'" -Pending {
# Have to change from using nuget to gist when we enable this test
(install-packageprovider -name nuget -MaximumVersion 2.8.5.122 -force).Version.ToString() | should match "2.8.5.122"
}
It "EXPECTED: success 'install a provider with MaximumVersion'" -Pending {
$a = (install-packageprovider -name gistprovider -force -Source $InternalGallery).Version.ToString()
$b = (install-packageprovider -name gistprovider -MinimumVersion 0.6 -force -Source $InternalSource).Version.ToString()
$a -eq $b | should be $true
}
}
Describe "Get-package with mulitiple providers" -Tags @('BVT', 'DRT'){
It "Get-package with multiple providers" -Pending {
$a = Install-package -Name TSDProvider -Source $InternalSource -ProviderName PowerShellGet -Force
$b = install-package -name TSDProvider -Source $InternalGallery -ProviderName NuGet -Force
$a.Name | should be "TSDProvider"
$b.Name | should be "TSDProvider"
$c = Get-Package -name TSDProvider
$c.Count -ge 2 | should be $true
$c | ?{ $_.ProviderName -eq "PowerShellGet" } | should not BeNullOrEmpty
$c | ?{ $_.ProviderName -eq "NuGet" } | should not BeNullOrEmpty
}
}
Describe "install-packageprovider Error Cases" -Tags @('BVT', 'DRT') {
AfterAll {
Unregister-PackageSource -Name OneGetTestSource -Verbose -ErrorAction SilentlyContinue
Unregister-PackageSource -Name OneGetTestSource2 -Verbose -ErrorAction SilentlyContinue
}
BeforeAll {
<#
#commented out as powershellget is not working yet
#make sure we are using the latest Nuget provider
Register-PackageSource -Name $InternalSource -Location $InternalGallery -ProviderName 'PowerShellGet' -Trusted -ForceBootstrap -ErrorAction SilentlyContinue
Register-PackageSource -Name $InternalSource2 -Location $InternalGallery2 -ProviderName 'PowerShellGet' -ForceBootstrap -ErrorAction SilentlyContinue
#>
}
It "install-packageprovider -name with wildcards, Expect error" -Pending {
$Error.Clear()
install-PackageProvider -name gist* -force -source $InternalGallery -warningaction:silentlycontinue -ErrorVariable wildcardError -ErrorAction SilentlyContinue
$wildcardError.FullyQualifiedErrorId| should be "WildCardCharsAreNotSupported,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "install-packageprovider - EXPECTED: returns an error when multiples sources contain the same package provider" -Pending {
$Error.Clear()
$providers = find-packageprovider -name gistprovider
$providers | ?{ $_.Source -match $InternalSource } | should not BeNullOrEmpty
$providers | ?{ $_.Source -match $InternalSource2 } | should not BeNullOrEmpty
install-packageprovider -name gistprovider -source @($InternalSource, $InternalSource2) -ErrorVariable theError -force
$theError.FullyQualifiedErrorId| should BeNullOrEmpty
}
It "install-package - EXPECTED: returns an error when multiples sources contain the same package provider" -Pending {
$Error.Clear()
$providers = find-package -name gistprovider
$providers | ?{ $_.Source -match $InternalSource } | should not BeNullOrEmpty
$providers | ?{ $_.Source -match $InternalSource2 } | should not BeNullOrEmpty
install-package -name gistprovider -force -Source @($InternalSource,$InternalSource2) -warningaction:silentlycontinue -ErrorVariable theError2 -ErrorAction SilentlyContinue
$theError2.FullyQualifiedErrorId| should BeNullOrEmpty
}
It "save-package - EXPECTED: returns an error when multiples sources contain the same package provider" -Pending {
$Error.Clear()
$providers = find-package -name gistprovider
$providers | ?{ $_.Source -match $InternalSource } | should not BeNullOrEmpty
$providers | ?{ $_.Source -match $InternalSource2 } | should not BeNullOrEmpty
if(-not (test-path $destination) ) {
mkdir $destination -ea silentlycontinue
}
save-package -name gistprovider -Source @($InternalSource,$InternalSource2) -path $destination -warningaction:silentlycontinue -ErrorVariable theError2 -ErrorAction SilentlyContinue
$theError2.FullyQualifiedErrorId| should BeNullOrEmpty
}
It "EXPECTED: returns an error when inputing a bad version format" {
$Error.Clear()
install-packageprovider -name nuget -RequiredVersion BOGUSVERSION -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "InvalidVersion,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider that does not exist" {
$Error.Clear()
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MinimumVersion" {
$Error.Clear()
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -RequiredVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with RequiredVersoin and MaximumVersion" {
$Error.Clear()
install-packageprovider -name NOT_EXISTS -Scope CurrentUser -RequiredVersion 1.0 -MaximumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "VersionRangeAndRequiredVersionCannotBeSpecifiedTogether,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with a MinimumVersion greater than MaximumVersion" {
$Error.Clear()
install-packageprovider -name nuget -Scope CurrentUser -MaximumVersion 1.0 -MinimumVersion 2.0 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MinimumVersion that does not exist" {
$Error.Clear()
install-packageprovider -name gistprovider -MinimumVersion 20.2 -warningaction:silentlycontinue -Scope CurrentUser -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
It "EXPECTED: returns an error when asking for a provider with MaximumVersion that does not exist" {
$Error.Clear()
install-packageprovider -name gistprovider -Scope CurrentUser -MaximumVersion 0.1 -warningaction:silentlycontinue -ea silentlycontinue
$ERROR[0].FullyQualifiedErrorId | should be "NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider"
}
}
File diff suppressed because it is too large. Load diff