From 4a438cde67a1509ec2e7a2b72ec026aa5e0c7bc2 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Thu, 16 Jun 2022 22:27:33 -0700 Subject: [PATCH 01/11] Update nuget client dependency packages --- src/code/PowerShellGet.csproj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/code/PowerShellGet.csproj b/src/code/PowerShellGet.csproj index 6d580abac..dbd51ee95 100644 --- a/src/code/PowerShellGet.csproj +++ b/src/code/PowerShellGet.csproj @@ -15,12 +15,12 @@ - - - - - - + + + + + + From f9f27fc55eaeb82d657c488bbccb434cacb9c32c Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 16:46:37 -0700 Subject: [PATCH 02/11] Update push runner to use a non-obsolete method --- src/code/PublishPSResource.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code/PublishPSResource.cs b/src/code/PublishPSResource.cs index f80f0ca5c..c3c465e63 100644 --- a/src/code/PublishPSResource.cs +++ b/src/code/PublishPSResource.cs @@ -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 { fullNupkgFile }, source: publishLocation, apiKey: ApiKey, symbolSource: null, From 61d03c56011b62d05a1cccd7fe3908aaa6d9c498 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 18:10:52 -0700 Subject: [PATCH 03/11] SilentlyContinue is not continuing, add error variable in attempt to debug --- test/InstallPSResource.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index 2f82c537e..01500cce0 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -102,7 +102,7 @@ Describe 'Test Install-PSResource for Module' { ) { param($Version, $Description) - Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue + Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue -ErrorVariable $ev $Error[0].FullyQualifiedErrorId | Should -be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" $res = Get-PSResource $testModuleName From 3b8bea74b6315f4b318143b9dcde9ea1e9d6abbc Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 19:11:33 -0700 Subject: [PATCH 04/11] Add try/catch block --- test/InstallPSResource.Tests.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index 01500cce0..9104358f5 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -102,7 +102,11 @@ Describe 'Test Install-PSResource for Module' { ) { param($Version, $Description) - Install-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository -ErrorAction SilentlyContinue -ErrorVariable $ev + 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 From 29bc881083e910d63b73fdef67bd91cf14f30ffd Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 19:35:13 -0700 Subject: [PATCH 05/11] Update error id for test --- test/InstallPSResource.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index 9104358f5..d0abc2010 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -107,7 +107,7 @@ Describe 'Test Install-PSResource for Module' { } catch {} - $Error[0].FullyQualifiedErrorId | Should -be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + $Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" $res = Get-PSResource $testModuleName $res | Should -BeNullOrEmpty From 106f1fd8d2b789689eec8fcd7754842219095aba Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 19:56:03 -0700 Subject: [PATCH 06/11] Update failing tests --- test/InstallPSResource.Tests.ps1 | 21 +++++++++++++++------ test/SavePSResource.Tests.ps1 | 25 +++++++++++++++++++------ test/UninstallPSResource.Tests.ps1 | 2 +- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index d0abc2010..952754ccb 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -96,12 +96,8 @@ 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 " -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 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 } @@ -113,6 +109,19 @@ Describe 'Test Install-PSResource for Module' { $res | Should -BeNullOrEmpty } + 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 + $res | Should -BeNullOrEmpty + } + It "Install resource when given Name, Version '*', should install the latest version" { Install-PSResource -Name $testModuleName -Version "*" -Repository $PSGalleryName -TrustRepository $pkg = Get-PSResource $testModuleName diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 1c3b612e1..3c9302900 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -99,13 +99,26 @@ 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 " -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 + $err.Count | Should -Not -Be 0 + $err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,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 diff --git a/test/UninstallPSResource.Tests.ps1 b/test/UninstallPSResource.Tests.ps1 index 0c0850e60..ceb9714c8 100644 --- a/test/UninstallPSResource.Tests.ps1 +++ b/test/UninstallPSResource.Tests.ps1 @@ -152,7 +152,7 @@ Describe 'Test Uninstall-PSResource for Modules' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository - Uninstall-PSResource -Name $testModuleName -Version $Version + Uninstall-PSResource -Name $testModuleName -Version $Version -ErrorAction SilentlyContinue $pkg = Get-PSResource $testModuleName -Version "1.0.0.0" $pkg.Version | Should -Be "1.0.0.0" } From ef144418fcd88c414d797a8eb055bcb7fd26308d Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 20:18:21 -0700 Subject: [PATCH 07/11] Update save and uninstall tests --- test/SavePSResource.Tests.ps1 | 6 +++--- test/UninstallPSResource.Tests.ps1 | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 3c9302900..644261b8f 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -102,7 +102,7 @@ Describe 'Test Save-PSResource for PSResources' { 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 + Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository } catch {} @@ -112,10 +112,10 @@ Describe 'Test Save-PSResource for PSResources' { $err[0].FullyQualifiedErrorId | Should -BeExactly "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } - It "Should not save resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]" { + 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 + Save-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -Path $SaveDir -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository } catch {} diff --git a/test/UninstallPSResource.Tests.ps1 b/test/UninstallPSResource.Tests.ps1 index ceb9714c8..a0bc31e30 100644 --- a/test/UninstallPSResource.Tests.ps1 +++ b/test/UninstallPSResource.Tests.ps1 @@ -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 -ErrorAction SilentlyContinue + 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" } From 293f3eaafdb52f60491df54e4c380108f8a7d196 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 20:39:04 -0700 Subject: [PATCH 08/11] Add test logging --- test/SavePSResource.Tests.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 644261b8f..3ce2bc44a 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -102,14 +102,16 @@ Describe 'Test Save-PSResource for PSResources' { 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 -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository + 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 + Write-Host ($Error[0]) + Write-Host ($Error[0].FullyQualifiedErrorId) + $Error[0].FullyQualifiedErrorId | Should -Be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } It "Should not save resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]"{ From 0335879c18e66fcd5bb70008eacdbe2bb4bdcfa1 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 20:53:23 -0700 Subject: [PATCH 09/11] Update save test --- test/SavePSResource.Tests.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index 3ce2bc44a..f85737ed2 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -109,9 +109,7 @@ Describe 'Test Save-PSResource for PSResources' { $pkgDir = Get-ChildItem -Path $SaveDir | Where-Object Name -eq $testModuleName $pkgDir | Should -BeNullOrEmpty $Error.Count | Should -Not -Be 0 - Write-Host ($Error[0]) - Write-Host ($Error[0].FullyQualifiedErrorId) - $Error[0].FullyQualifiedErrorId | Should -Be "ResourceNotFoundError,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" + $Error[0].FullyQualifiedErrorId | Should -Be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.SavePSResource" } It "Should not save resource with incorrectly formatted version such as version formatted with invalid delimiter [1-0-0-0]"{ From ad1f9f5482b378bf665d93197ea99223e492d8dd Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Mon, 20 Jun 2022 20:54:16 -0700 Subject: [PATCH 10/11] Use default error variable in tests --- test/SavePSResource.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/SavePSResource.Tests.ps1 b/test/SavePSResource.Tests.ps1 index f85737ed2..b9ddac47d 100644 --- a/test/SavePSResource.Tests.ps1 +++ b/test/SavePSResource.Tests.ps1 @@ -115,14 +115,14 @@ Describe 'Test Save-PSResource for PSResources' { 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 -ErrorVariable err -ErrorAction SilentlyContinue -TrustRepository + 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" { From e52c88fd79a1b28340a8e505c7fe314c0dc66064 Mon Sep 17 00:00:00 2001 From: Amber Erickson Date: Tue, 21 Jun 2022 10:49:59 -0700 Subject: [PATCH 11/11] Add comment to tests --- test/InstallPSResource.Tests.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/test/InstallPSResource.Tests.ps1 b/test/InstallPSResource.Tests.ps1 index 952754ccb..e2666efb0 100644 --- a/test/InstallPSResource.Tests.ps1 +++ b/test/InstallPSResource.Tests.ps1 @@ -96,6 +96,7 @@ Describe 'Test Install-PSResource for Module' { $pkg.Version | Should -Be "3.0.0.0" } + # 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 {