Skip to content

Update nuget client dependency packages #678

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 11 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/code/PowerShellGet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<ItemGroup>
<PackageReference Include="LinqKit.Core" Version="1.1.17" />
<PackageReference Include="morelinq" Version="3.3.2" />
<PackageReference Include="NuGet.Commands" Version="5.8.0" />
<PackageReference Include="NuGet.Common" Version="5.8.0" />
<PackageReference Include="NuGet.Configuration" Version="5.8.0" />
<PackageReference Include="NuGet.Packaging" Version="5.8.0" />
<PackageReference Include="NuGet.ProjectModel" Version="5.8.0" />
<PackageReference Include="NuGet.Protocol" Version="5.8.0" />
<PackageReference Include="NuGet.Commands" Version="6.2.1" />
<PackageReference Include="NuGet.Common" Version="6.2.1" />
<PackageReference Include="NuGet.Configuration" Version="6.2.1" />
<PackageReference Include="NuGet.Packaging" Version="6.2.1" />
<PackageReference Include="NuGet.ProjectModel" Version="6.2.1" />
<PackageReference Include="NuGet.Protocol" Version="6.2.1" />
<PackageReference Include="NuGet.Repositories" Version="4.3.0-beta1-2418" />
<PackageReference Include="PowerShellStandard.Library" Version="7.0.0-preview.1" />
<PackageReference Include="System.Data.DataSetExtensions" Version="4.6.0-preview3.19128.7" />
Expand Down
2 changes: 1 addition & 1 deletion src/code/PublishPSResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ private bool PushNupkg(string outputNupkgDir, string repoName, string repoUri, o
PushRunner.Run(
settings: Settings.LoadDefaultSettings(root: null, configFileName: null, machineWideSettings: null),
sourceProvider: new PackageSourceProvider(settings),
packagePath: fullNupkgFile,
packagePaths: new List<string> { fullNupkgFile },
source: publishLocation,
apiKey: ApiKey,
symbolSource: null,
Expand Down
26 changes: 20 additions & 6 deletions test/InstallPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,27 @@ Describe 'Test Install-PSResource for Module' {
$pkg.Version | Should -Be "3.0.0.0"
}

It "Should not install resource with incorrectly formatted version such as <Description>" -TestCases @(
@{Version='(1.0.0.0)'; Description="exclusive version (1.0.0.0)"},
@{Version='[1-0-0-0]'; Description="version formatted with invalid delimiter [1-0-0-0]"}
) {
param($Version, $Description)
# TODO: Update this test and others like it that use try/catch blocks instead of Should -Throw
It "Should not install resource with incorrectly formatted version such as exclusive version (1.0.0.0)" {
$Version = "(1.0.0.0)"
try {
Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
}
catch
{}
$Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"
Copy link
Contributor

Choose a reason for hiding this comment

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

We should really be using the 'Should -Throw' pattern here. But I don't think it is worth changing here. Can you add a comment to update these tests later?

{} | Should -Throw -ErrorId "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I had it in my head that Should -Throw was for terminating errors. I'll add that comment


$res = Get-PSResource $testModuleName
$res | Should -BeNullOrEmpty
}

Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
It "Should not install resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]" {
$Version="[1-0-0-0]"
try {
Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue
}
catch
{}
$Error[0].FullyQualifiedErrorId | Should -be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource"

$res = Get-PSResource $testModuleName
Expand Down
29 changes: 21 additions & 8 deletions test/SavePSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,30 @@ Describe 'Test Save-PSResource for PSResources' {
$pkgDirVersion.Name | Should -Be "3.0.0.0"
}

It "Should not save resource with incorrectly formatted version such as <Description>" -TestCases @(
@{Version='(1.0.0.0)'; Description="exclusive version (1.0.0.0)"},
@{Version='[1-0-0-0]'; Description="version formatted with invalid delimiter [1-0-0-0]"}
) {
param($Version, $Description)
It "Should not save resource with incorrectly formatted version such as exclusive version (1.0.0.0)" {
$Version="(1.0.0.0)"
try {
Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorAction SilentlyContinue -TrustRepository
}
catch
{}
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName
$pkgDir | Should -BeNullOrEmpty
$Error.Count | Should -Not -Be 0
$Error[0].FullyQualifiedErrorId | Should -Be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
}

Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository
It "Should not save resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]"{
$Version = "[1-0-0-0]"
try {
Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorAction SilentlyContinue -TrustRepository
}
catch
{}
$pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName
$pkgDir | Should -BeNullOrEmpty
$err.Count | Should -Not -Be 0
$err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
$Error.Count | Should -Not -Be 0
$Error[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource"
}

It "Save resource when given Name, Version '*', should install the latest version" {
Expand Down
6 changes: 5 additions & 1 deletion test/UninstallPSResource.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ Describe 'Test Uninstall-PSResource for Modules' {

Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository

Uninstall-PSResource -Name $testModuleName -Version $Version
try {
Uninstall-PSResource -Name $testModuleName -Version $Version -ErrorAction SilentlyContinue
}
catch
{}
$pkg = Get-PSResource $testModuleName -Version "1.0.0.0"
$pkg.Version | Should -Be "1.0.0.0"
}
Expand Down