diff --git a/src/PowerShellGet.psd1 b/src/PowerShellGet.psd1 index ce2a18da4..66eea7c87 100644 --- a/src/PowerShellGet.psd1 +++ b/src/PowerShellGet.psd1 @@ -15,15 +15,15 @@ FormatsToProcess = 'PSGet.Format.ps1xml' CmdletsToExport = @( 'Find-PSResource', - 'Get-PSResource', + 'Get-InstalledPSResource', 'Get-PSResourceRepository', 'Get-PSScriptFileInfo', 'Install-PSResource', 'Register-PSResourceRepository', 'Save-PSResource', 'Set-PSResourceRepository', - 'New-PSScriptFileInfo', - 'Test-PSScriptFileInfo', + 'New-PSScriptFile', + 'Test-PSScriptFile', 'Update-PSScriptFileInfo', 'Publish-PSResource', 'Uninstall-PSResource', @@ -48,7 +48,7 @@ ## 3.0.20-beta20 - Move off of NuGet client APIs and use direct REST API calls for remote repositories (#1023) - + ### Bug Fixes - Updates to dependency installation (#1010) (#996) (#907) - Update to retrieving all packages installed on machine (#999) @@ -57,7 +57,7 @@ - `Find-PSResource` no longer returns duplicate results (#755) - `Find-PSResource` lists repository 'PSGalleryScripts' which does not exist for `Get-PSResourceRepository` (#1028) -## 3.0.19-beta19 +## 3.0.19-beta19 ### New Features - Add `-SkipModuleManifestValidate` parameter to `Publish-PSResource` (#904) diff --git a/src/code/GetHelper.cs b/src/code/GetHelper.cs index c0d3a43b0..bf4f96f5c 100644 --- a/src/code/GetHelper.cs +++ b/src/code/GetHelper.cs @@ -13,7 +13,7 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets { /// - /// Get helper class provides the core functionality for Get-PSResource. + /// Get helper class provides the core functionality for Get-InstalledPSResource. /// internal class GetHelper { @@ -38,7 +38,7 @@ public GetHelper(PSCmdlet cmdletPassedIn) #region Public methods /// - /// Retrieves package paths from provided search paths for installed packages + /// Retrieves package paths from provided search paths for installed packages /// by name *and* version. /// public IEnumerable GetInstalledPackages( @@ -134,7 +134,7 @@ public List FilterPkgPathsByName(string[] names, List dirsToSear public IEnumerable FilterPkgPathsByVersion(VersionRange versionRange, List dirsToSearch, bool selectPrereleaseOnly) { Dbg.Assert(versionRange != null, "Version Range cannot be null"); - + // if no version is specified, just get the latest version foreach (string pkgPath in dirsToSearch) { @@ -177,7 +177,7 @@ public IEnumerable FilterPkgPathsByVersion(VersionRange versionRange, Li // For Uninstall-PSResource Prerelease parameter equates to selecting prerelease versions only to uninstall. // For other cmdlets (Find-PSResource, Install-PSResource) Prerelease parmater equates to selecting stable and prerelease versions. - // We will not just select prerelase versions. For Get-PSResource, there is no Prerelease parameter. + // We will not just select prerelase versions. For Get-InstalledPSResource, there is no Prerelease parameter. if (versionRange.Satisfies(pkgNugetVersion)) { if (!selectPrereleaseOnly || pkgNugetVersion.IsPrerelease) diff --git a/src/code/GetPSResource.cs b/src/code/GetInstalledPSResource.cs similarity index 92% rename from src/code/GetPSResource.cs rename to src/code/GetInstalledPSResource.cs index 543ec41c6..a5ebfe64f 100644 --- a/src/code/GetPSResource.cs +++ b/src/code/GetInstalledPSResource.cs @@ -13,9 +13,9 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets /// It retrieves a resource that was installed with Install-PSResource /// Returns a single resource or multiple resource. /// - [Cmdlet(VerbsCommon.Get, "PSResource")] + [Cmdlet(VerbsCommon.Get, "InstalledPSResource")] [OutputType(typeof(PSResourceInfo))] - public sealed class GetPSResource : PSCmdlet + public sealed class GetInstalledPSResourceCommand : PSCmdlet { #region Members @@ -34,7 +34,7 @@ public sealed class GetPSResource : PSCmdlet public string[] Name { get; set; } /// - /// Specifies the version of the resource to include to look for. + /// Specifies the version of the resource to include to look for. /// [SupportsWildcards] [Parameter] @@ -42,12 +42,12 @@ public sealed class GetPSResource : PSCmdlet public string Version { get; set; } /// - /// Specifies the path to look in. + /// Specifies the path to look in. /// [Parameter] [ValidateNotNullOrEmpty()] public string Path { get; set; } - + /// /// Specifies the scope of installation. /// @@ -60,7 +60,7 @@ public sealed class GetPSResource : PSCmdlet protected override void BeginProcessing() { - // Validate that if a -Version param is passed in that it can be parsed into a NuGet version range. + // Validate that if a -Version param is passed in that it can be parsed into a NuGet version range. // an exact version will be formatted into a version range. if (Version == null) { @@ -117,7 +117,7 @@ protected override void BeginProcessing() protected override void ProcessRecord() { - WriteVerbose("Entering GetPSResource"); + WriteVerbose("Entering GetInstalledPSResource"); var namesToSearch = Utils.ProcessNameWildcards(Name, removeWildcardEntries:false, out string[] errorMsgs, out bool _); foreach (string error in errorMsgs) diff --git a/src/code/NewPSScriptFileInfo.cs b/src/code/NewPSScriptFile.cs similarity index 97% rename from src/code/NewPSScriptFileInfo.cs rename to src/code/NewPSScriptFile.cs index fe652b7fc..088c82295 100644 --- a/src/code/NewPSScriptFileInfo.cs +++ b/src/code/NewPSScriptFile.cs @@ -13,8 +13,8 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets /// /// Creates a new .ps1 file with script information required for publishing a script. /// - [Cmdlet(VerbsCommon.New, "PSScriptFileInfo")] - public sealed class NewPSScriptFileInfo : PSCmdlet + [Cmdlet(VerbsCommon.New, "PSScriptFile")] + public sealed class NewPSScriptFile : PSCmdlet { #region Parameters @@ -182,7 +182,7 @@ protected override void EndProcessing() var exMessage = "Path needs to end with a .ps1 file. Example: C:/Users/john/x/MyScript.ps1"; var ex = new ArgumentException(exMessage); var InvalidPathError = new ErrorRecord(ex, "InvalidPath", ErrorCategory.InvalidArgument, null); - ThrowTerminatingError(InvalidPathError); + ThrowTerminatingError(InvalidPathError); } var resolvedPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(Path); @@ -193,7 +193,7 @@ protected override void EndProcessing() var InvalidPathArgumentError = new ErrorRecord(ex, "InvalidPathArgumentError", ErrorCategory.InvalidArgument, null); ThrowTerminatingError(InvalidPathArgumentError); } - + if (File.Exists(resolvedPath) && !Force) { // .ps1 file at specified location already exists and Force parameter isn't used to rewrite the file @@ -250,7 +250,7 @@ protected override void EndProcessing() return; } - File.WriteAllLines(resolvedPath, psScriptFileContents); + File.WriteAllLines(resolvedPath, psScriptFileContents); } #endregion diff --git a/src/code/PSScriptContents.cs b/src/code/PSScriptContents.cs index 63f1c4e80..e81b6484b 100644 --- a/src/code/PSScriptContents.cs +++ b/src/code/PSScriptContents.cs @@ -67,7 +67,7 @@ internal void ParseContent(string[] commentLines) /// /// This function is called by PSScriptFileInfo.TryCreateScriptFileInfoString(), - /// by the New-PSScriptFileInfo cmdlet (in which case EndOfFileContents is an empty string so there's no signature that'll get removed) + /// by the New-PSScriptFile cmdlet (in which case EndOfFileContents is an empty string so there's no signature that'll get removed) /// or by Update-PSScriptFileInfo cmdlet (in which case EndOfFileContents may not be empty and may contain a signature. /// When emitting contents, any file signature is always removed because it is invalidated when the content is updated. /// @@ -80,7 +80,7 @@ internal string[] EmitContent() #endregion #region Private Methods - + /// /// Checks if the end of file contents contain a signature. /// @@ -106,9 +106,9 @@ private void RemoveSignatureString() { if (ContainsSignature) { - // The script signature comment block always appears at the end of the script file, - // so its start location becomes the end of the content section after the signature - // comment block is removed, and is also the length of the content section minus the + // The script signature comment block always appears at the end of the script file, + // so its start location becomes the end of the content section after the signature + // comment block is removed, and is also the length of the content section minus the // signature block. string[] contentsWithoutSignature = new string[_signatureStartIndex]; Array.Copy(ScriptContents, contentsWithoutSignature, _signatureStartIndex); diff --git a/src/code/TestPSScriptFileInfo.cs b/src/code/TestPSScriptFile.cs similarity index 92% rename from src/code/TestPSScriptFileInfo.cs rename to src/code/TestPSScriptFile.cs index 2b4775115..46473aaaf 100644 --- a/src/code/TestPSScriptFileInfo.cs +++ b/src/code/TestPSScriptFile.cs @@ -12,9 +12,9 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets /// Tests the contents of a .ps1 file to see if it has all properties and is in correct format /// for publishing the script with the file. /// - [Cmdlet(VerbsDiagnostic.Test, "PSScriptFileInfo")] + [Cmdlet(VerbsDiagnostic.Test, "PSScriptFile")] [OutputType(typeof(bool))] - public sealed class TestPSScriptFileInfo : PSCmdlet + public sealed class TestPSScriptFile : PSCmdlet { #region Parameters @@ -36,7 +36,7 @@ protected override void EndProcessing() var exMessage = "Path needs to end with a .ps1 file. Example: C:/Users/john/x/MyScript.ps1"; var ex = new ArgumentException(exMessage); var InvalidPathError = new ErrorRecord(ex, "InvalidPath", ErrorCategory.InvalidArgument, null); - ThrowTerminatingError(InvalidPathError); + ThrowTerminatingError(InvalidPathError); } var resolvedPaths = SessionState.Path.GetResolvedPSPathFromPSPath(Path); @@ -62,7 +62,7 @@ protected override void EndProcessing() scriptFileInfoPath: resolvedPath, parsedScript: out PSScriptFileInfo _, errors: out ErrorRecord[] errors, - out string[] verboseMsgs); + out string[] verboseMsgs); if (!isValidScript) { diff --git a/test/GetPSResource.Tests.ps1 b/test/GetInstalledPSResource.Tests.ps1 similarity index 85% rename from test/GetPSResource.Tests.ps1 rename to test/GetInstalledPSResource.Tests.ps1 index 6439add32..470f0ea68 100644 --- a/test/GetPSResource.Tests.ps1 +++ b/test/GetInstalledPSResource.Tests.ps1 @@ -4,7 +4,7 @@ $ProgressPreference = "SilentlyContinue" Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force -Describe 'Test Get-PSResource for Module' -Tags 'CI' { +Describe 'Test Get-InstalledPSResource for Module' -Tags 'CI' { BeforeAll{ $PSGalleryName = Get-PSGalleryName @@ -26,17 +26,17 @@ Describe 'Test Get-PSResource for Module' -Tags 'CI' { } It "Get resources without any parameter values" { - $pkgs = Get-PSResource + $pkgs = Get-InstalledPSResource $pkgs.Count | Should -BeGreaterThan 1 } It "Get specific module resource by name" { - $pkg = Get-PSResource -Name $testModuleName + $pkg = Get-InstalledPSResource -Name $testModuleName $pkg.Name | Should -Contain $testModuleName } It "Get specific script resource by name" { - $pkg = Get-PSResource -Name $testScriptName + $pkg = Get-InstalledPSResource -Name $testScriptName $pkg.Name | Should -Be $testScriptName } @@ -47,11 +47,11 @@ Describe 'Test Get-PSResource for Module' -Tags 'CI' { @{Name="tes*ule"; ExpectedName=$testModuleName; Reason="validate name, with wildcard in middle of name: tes*ule"} ) { param($Version, $ExpectedVersion) - $pkgs = Get-PSResource -Name $Name + $pkgs = Get-InstalledPSResource -Name $Name $pkgs.Name | Should -Contain $testModuleName } -$testCases = +$testCases = @{Version="[1.0.0.0]"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match"}, @{Version="1.0.0.0"; ExpectedVersion="1.0.0.0"; Reason="validate version, exact match without bracket syntax"}, @{Version="[1.0.0.0, 5.0.0.0]"; ExpectedVersion=@("5.0.0.0", "3.0.0.0", "1.0.0.0"); Reason="validate version, exact range inclusive"}, @@ -64,7 +64,7 @@ $testCases = It "Get resource when given Name to " -TestCases $testCases { param($Version, $ExpectedVersion) - $pkgs = Get-PSResource -Name $testModuleName -Version $Version + $pkgs = Get-InstalledPSResource -Name $testModuleName -Version $Version $pkgs.Name | Should -Contain $testModuleName $pkgs.Version | Should -Be $ExpectedVersion } @@ -86,7 +86,7 @@ $testCases = $res = Find-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -ErrorAction Ignore } catch {} - + $res | Should -BeNullOrEmpty } @@ -103,20 +103,20 @@ $testCases = $res = Find-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -ErrorAction Ignore } catch {} - + $res | Should -BeNullOrEmpty } It "Get resources when given Name, and Version is '*'" { - $pkgs = Get-PSResource -Name $testModuleName -Version "*" + $pkgs = Get-InstalledPSResource -Name $testModuleName -Version "*" $pkgs.Count | Should -BeGreaterOrEqual 2 } It "Get prerelease version module when version with correct prerelease label is specified" { Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName -Version "5.2.5" + $res = Get-InstalledPSResource -Name $testModuleName -Version "5.2.5" $res | Should -BeNullOrEmpty - $res = Get-PSResource -Name $testModuleName -Version "5.2.5-alpha001" + $res = Get-InstalledPSResource -Name $testModuleName -Version "5.2.5-alpha001" $res.Name | Should -Be $testModuleName $res.Version | Should -Be "5.2.5" $res.Prerelease | Should -Be "alpha001" @@ -124,9 +124,9 @@ $testCases = It "Get prerelease version script when version with correct prerelease label is specified" { Install-PSResource -Name $testScriptName -Version "3.0.0-alpha" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testScriptName -Version "3.0.0" + $res = Get-InstalledPSResource -Name $testScriptName -Version "3.0.0" $res | Should -BeNullOrEmpty - $res = Get-PSResource -Name $testScriptName -Version "3.0.0-alpha" + $res = Get-InstalledPSResource -Name $testScriptName -Version "3.0.0-alpha" $res.Name | Should -Be $testScriptName $res.Version | Should -Be "3.0.0" $res.Prerelease | Should -Be "alpha" @@ -134,21 +134,21 @@ $testCases = # Windows only It "Get resource under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) { - $pkg = Get-PSResource -Name $testModuleName -Scope CurrentUser + $pkg = Get-InstalledPSResource -Name $testModuleName -Scope CurrentUser $pkg[0].Name | Should -Be $testModuleName $pkg[0].InstalledLocation.ToString().Contains("Documents") | Should -Be $true } # Windows only It "Get resource under AllUsers scope when module is installed under CurrentUser - Windows only" -Skip:(!(Get-IsWindows)) { - $pkg = Get-PSResource -Name $testModuleName -Scope AllUsers + $pkg = Get-InstalledPSResource -Name $testModuleName -Scope AllUsers $pkg | Should -BeNullOrEmpty } # Windows only It "Get resource under AllUsers scope - Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers - $pkg = Get-PSResource -Name $testModuleName -Scope AllUsers + $pkg = Get-InstalledPSResource -Name $testModuleName -Scope AllUsers $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Program Files") | Should -Be $true } @@ -157,7 +157,7 @@ $testCases = It "Get resource under CurrentUser scope when module is installed under AllUsers - Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) { Uninstall-PSResource -Name $testModuleName -Version "*" Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers - $pkg = Get-PSResource -Name $testModuleName -Scope CurrentUser + $pkg = Get-InstalledPSResource -Name $testModuleName -Scope CurrentUser $pkg | Should -BeNullOrEmpty } @@ -165,7 +165,7 @@ $testCases = # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Get resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name "testmodule99" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource "testmodule99" -Scope CurrentUser + $pkg = Get-InstalledPSResource "testmodule99" -Scope CurrentUser $pkg.Name | Should -contain "testmodule99" $pkg.InstalledLocation.ToString().Contains("/.local") | Should -Be $true } diff --git a/test/GetPSScriptFileInfo.Tests.ps1 b/test/GetPSScriptFileInfo.Tests.ps1 index b6d011dee..5a24b28ad 100644 --- a/test/GetPSScriptFileInfo.Tests.ps1 +++ b/test/GetPSScriptFileInfo.Tests.ps1 @@ -16,12 +16,12 @@ Describe "Test Get-PSScriptFileInfo" -Tags 'CI' { $script:testScriptsFolderPath = Join-Path $testFilesFolderPath -ChildPath "testScripts" } - It "should get script file object given script with minimal required fields" { + It "should get script file object given script with minimal required fields" { $scriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "testscript.ps1" $scriptDescription = "this is a test script" - New-PSScriptFileInfo -Path $scriptFilePath -Description $scriptDescription - - $res = Get-PSScriptFileInfo $scriptFilePath + New-PSScriptFile -Path $scriptFilePath -Description $scriptDescription + + $res = Get-PSScriptFileInfo $scriptFilePath $res.Name | Should -Be "testscript" $res.ScriptHelpComment.Description | Should -Be $scriptDescription } @@ -56,15 +56,15 @@ Describe "Test Get-PSScriptFileInfo" -Tags 'CI' { $scriptName = "ScriptWithoutEmptyLinesInMetadata.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - $res = Get-PSScriptFileInfo $scriptFilePath - $res.Name | Should -Be "ScriptWithoutEmptyLinesInMetadata" + $res = Get-PSScriptFileInfo $scriptFilePath + $res.Name | Should -Be "ScriptWithoutEmptyLinesInMetadata" } It "should get script file object given script without empty lines between comment blocks" { $scriptName = "ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - $res = Get-PSScriptFileInfo $scriptFilePath + $res = Get-PSScriptFileInfo $scriptFilePath $res.Name | Should -Be "ScriptWithoutEmptyLinesBetweenCommentBlocks" } @@ -72,7 +72,7 @@ Describe "Test Get-PSScriptFileInfo" -Tags 'CI' { $scriptName = "ScriptWithInvalidProjectUri.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - $res = Get-PSScriptFileInfo $scriptFilePath + $res = Get-PSScriptFileInfo $scriptFilePath $res.Name | Should -Be "ScriptWithInvalidProjectUri" $res.ScriptMetadataComment.ProjectUri | Should -BeNullOrEmpty } diff --git a/test/InstallPSResourceTests/InstallPSResourceLocal.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceLocal.Tests.ps1 index 052be4731..18fb21481 100644 --- a/test/InstallPSResourceTests/InstallPSResourceLocal.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceLocal.Tests.ps1 @@ -41,48 +41,48 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { It "Install resource given Name parameter" { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "5.0.0.0" } It "Install resource given Name and Version (specific) parameters" { Install-PSResource -Name $testModuleName -Version "3.0.0" -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "3.0.0.0" } It "Install multiple resources by name" { $pkgNames = @($testModuleName, $testModuleName2) - Install-PSResource -Name $pkgNames -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $pkgNames + Install-PSResource -Name $pkgNames -Repository $localRepo -TrustRepository + $pkg = Get-InstalledPSResource $pkgNames $pkg.Name | Should -Be $pkgNames } It "Should not install resource given nonexistant name" { Install-PSResource -Name "NonExistantModule" -Repository $localRepo -TrustRepository - $res = Get-PSResource "NonExistantModule" + $res = Get-InstalledPSResource "NonExistantModule" $res.Name | Should -BeNullOrEmpty } It "Should install resource given name and exact version with bracket syntax" { - Install-PSResource -Name $testModuleName -Version "[1.0.0.0]" -Repository $localRepo -TrustRepository - $res = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "[1.0.0.0]" -Repository $localRepo -TrustRepository + $res = Get-InstalledPSResource $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "1.0.0.0" } It "Should install resource given name and exact range inclusive [1.0.0.0, 5.0.0.0]" { Install-PSResource -Name $testModuleName -Version "[1.0.0.0, 5.0.0.0]" -Repository $localRepo -TrustRepository - $res = Get-PSResource $testModuleName + $res = Get-InstalledPSResource $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "5.0.0.0" } It "Should install resource given name and exact range exclusive (1.0.0.0, 5.0.0.0)" { - Install-PSResource -Name $testModuleName -Version "(1.0.0.0, 5.0.0.0)" -Repository $localRepo -TrustRepository - $res = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "(1.0.0.0, 5.0.0.0)" -Repository $localRepo -TrustRepository + $res = Get-InstalledPSResource $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "3.0.0.0" } @@ -96,43 +96,43 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { {} $Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" - $res = Get-PSResource $testModuleName + $res = Get-InstalledPSResource $testModuleName $res | Should -BeNullOrEmpty } It "Install resource when given Name, Version '*', should install the latest version" { Install-PSResource -Name $testModuleName -Version "*" -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install resource with latest (including prerelease) version given Prerelease parameter" { - Install-PSResource -Name $testModuleName -Prerelease -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Prerelease -Repository $localRepo -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.2.5" $pkg.Prerelease | Should -Be "alpha001" } It "Install resource via InputObject by piping from Find-PSresource" { - Find-PSResource -Name $testModuleName -Repository $localRepo | Install-PSResource -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + Find-PSResource -Name $testModuleName -Repository $localRepo | Install-PSResource -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install resource under location specified in PSModulePath" { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName ($env:PSModulePath).Contains($pkg.InstalledLocation) } # Windows only It "Install resource under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -147,8 +147,8 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { # Windows only It "Install resource under no specified scope - Windows only" -Skip:(!(Get-IsWindows)) { - Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -157,7 +157,7 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } @@ -166,14 +166,14 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under no specified scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } It "Should not install resource that is already installed" { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository -WarningVariable WarningVar -warningaction SilentlyContinue $WarningVar | Should -Not -BeNullOrEmpty @@ -181,18 +181,18 @@ Describe 'Test Install-PSResource for local repositories' -tags 'CI' { It "Reinstall resource that is already installed with -Reinstall parameter" { Install-PSResource -Name $testModuleName -Repository $localRepo -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" Install-PSResource -Name $testModuleName -Repository $localRepo -Reinstall -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install module using -WhatIf, should not install the module" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $localRepo -TrustRepository -WhatIf - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $res | Should -BeNullOrEmpty } diff --git a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 index 65eb73a1c..219564832 100644 --- a/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceV2Server.Tests.ps1 @@ -46,58 +46,58 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install specific module resource by name" { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install specific script resource by name" { Install-PSResource -Name $testScriptName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testScriptName + $pkg = Get-InstalledPSResource $testScriptName $pkg.Name | Should -Be $testScriptName $pkg.Version | Should -Be "3.5.0.0" } It "Install multiple resources by name" { $pkgNames = @($testModuleName, $testModuleName2) - Install-PSResource -Name $pkgNames -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $pkgNames + Install-PSResource -Name $pkgNames -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $pkgNames $pkg.Name | Should -Be $pkgNames } It "Should not install resource given nonexistant name" { Install-PSResource -Name "NonExistantModule" -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue - $pkg = Get-PSResource "NonExistantModule" + $pkg = Get-InstalledPSResource "NonExistantModule" $pkg.Name | Should -BeNullOrEmpty $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" } # Do some version testing, but Find-PSResource should be doing thorough testing It "Should install resource given name and exact version" { Install-PSResource -Name $testModuleName -Version "1.0.0" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "1.0.0.0" } It "Should install resource given name and exact version with bracket syntax" { - Install-PSResource -Name $testModuleName -Version "[1.0.0]" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "[1.0.0]" -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "1.0.0.0" } It "Should install resource given name and exact range inclusive [1.0.0, 5.0.0]" { - Install-PSResource -Name $testModuleName -Version "[1.0.0, 5.0.0]" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "[1.0.0, 5.0.0]" -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Should install resource given name and exact range exclusive (1.0.0, 5.0.0)" { - Install-PSResource -Name $testModuleName -Version "(1.0.0, 5.0.0)" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "(1.0.0, 5.0.0)" -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "3.0.0.0" } @@ -112,20 +112,20 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { {} $Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" - $res = Get-PSResource $testModuleName + $res = Get-InstalledPSResource $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 + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install resource with latest (including prerelease) version given Prerelease parameter" { - Install-PSResource -Name $testModuleName -Prerelease -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Prerelease -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.2.5" $pkg.Prerelease | Should -Be "alpha001" @@ -133,17 +133,17 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install a module with a dependency" { Uninstall-PSResource -Name "TestModuleWithDependency*" -Version "*" -SkipDependencyCheck -ErrorAction SilentlyContinue - Install-PSResource -Name "TestModuleWithDependencyC" -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository + Install-PSResource -Name "TestModuleWithDependencyC" -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource "TestModuleWithDependencyC" + $pkg = Get-InstalledPSResource "TestModuleWithDependencyC" $pkg.Name | Should -Be "TestModuleWithDependencyC" $pkg.Version | Should -Be "1.0" - $pkg = Get-PSResource "TestModuleWithDependencyB" + $pkg = Get-InstalledPSResource "TestModuleWithDependencyB" $pkg.Name | Should -Be "TestModuleWithDependencyB" $pkg.Version | Should -Be "3.0" - $pkg = Get-PSResource "TestModuleWithDependencyD" + $pkg = Get-InstalledPSResource "TestModuleWithDependencyD" $pkg.Name | Should -Be "TestModuleWithDependencyD" $pkg.Version | Should -Be "1.0" } @@ -151,31 +151,31 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install a module with a dependency and skip installing the dependency" { Uninstall-PSResource -Name "TestModuleWithDependency*" -Version "*" -SkipDependencyCheck Install-PSResource -Name "TestModuleWithDependencyC" -Version "1.0.0.0" -SkipDependencyCheck -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource "TestModuleWithDependencyC" + $pkg = Get-InstalledPSResource "TestModuleWithDependencyC" $pkg.Name | Should -Be "TestModuleWithDependencyC" $pkg.Version | Should -Be "1.0" - $pkg = Get-PSResource "TestModuleWithDependencyB", "TestModuleWithDependencyD" + $pkg = Get-InstalledPSResource "TestModuleWithDependencyB", "TestModuleWithDependencyD" $pkg | Should -BeNullOrEmpty } It "Install resource via InputObject by piping from Find-PSresource" { - Find-PSResource -Name $testModuleName -Repository $PSGalleryName | Install-PSResource -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + Find-PSResource -Name $testModuleName -Repository $PSGalleryName | Install-PSResource -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } It "Install resource under specified in PSModulePath" { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName ($env:PSModulePath).Contains($pkg.InstalledLocation) } It "Install resource with companyname, copyright and repository source location and validate" { Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository PSGallery -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Version | Should -Be "5.2.5" $pkg.Prerelease | Should -Be "alpha001" @@ -188,7 +188,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install script with companyname, copyright, and repository source location and validate" { Install-PSResource -Name "Install-VSCode" -Version "1.4.2" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource "Install-VSCode" -Version "1.4.2" + $res = Get-InstalledPSResource "Install-VSCode" -Version "1.4.2" $res.Name | Should -Be "Install-VSCode" $res.Version | Should -Be "1.4.2" $res.CompanyName | Should -Be "Microsoft Corporation" @@ -199,7 +199,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # Windows only It "Install resource under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -214,8 +214,8 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # Windows only It "Install resource under no specified scope - Windows only" -Skip:(!(Get-IsWindows)) { - Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -224,7 +224,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } @@ -233,14 +233,14 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under no specified scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } It "Should not install resource that is already installed" { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -WarningVariable WarningVar -warningaction SilentlyContinue $WarningVar | Should -Not -BeNullOrEmpty @@ -248,18 +248,18 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Reinstall resource that is already installed with -Reinstall parameter" { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" Install-PSResource -Name $testModuleName -Repository $PSGalleryName -Reinstall -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0.0" } # It "Restore resource after reinstall fails" { # Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - # $pkg = Get-PSResource $testModuleName + # $pkg = Get-InstalledPSResource $testModuleName # $pkg.Name | Should -Contain $testModuleName # $pkg.Version | Should -Contain "5.0.0.0" @@ -285,43 +285,43 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # It "Install resource that requires accept license with -AcceptLicense flag" { # Install-PSResource -Name "testModuleWithlicense" -Repository $TestGalleryName -AcceptLicense - # $pkg = Get-PSResource "testModuleWithlicense" - # $pkg.Name | Should -Be "testModuleWithlicense" + # $pkg = Get-InstalledPSResource "testModuleWithlicense" + # $pkg.Name | Should -Be "testModuleWithlicense" # $pkg.Version | Should -Be "0.0.3.0" # } It "Install resource with cmdlet names from a module already installed (should clobber)" { Install-PSResource -Name "CLobberTestModule1" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource "ClobberTestModule1" - $pkg.Name | Should -Be "ClobberTestModule1" + $pkg = Get-InstalledPSResource "ClobberTestModule1" + $pkg.Name | Should -Be "ClobberTestModule1" $pkg.Version | Should -Be "0.0.1" Install-PSResource -Name "ClobberTestModule2" -Repository $PSGalleryName -TrustRepository - $pkg = Get-PSResource "ClobberTestModule2" - $pkg.Name | Should -Be "ClobberTestModule2" + $pkg = Get-InstalledPSResource "ClobberTestModule2" + $pkg.Name | Should -Be "ClobberTestModule2" $pkg.Version | Should -Be "0.0.1" } It "Install module using -WhatIf, should not install the module" { Install-PSResource -Name $testModuleName -WhatIf - - $res = Get-PSResource $testModuleName + + $res = Get-InstalledPSResource $testModuleName $res | Should -BeNullOrEmpty } It "Validates that a module with module-name script files (like Pester) installs under Modules path" { Install-PSResource -Name "testModuleWithScript" -Repository $PSGalleryName -TrustRepository - - $res = Get-PSResource "testModuleWithScript" + + $res = Get-InstalledPSResource "testModuleWithScript" $res.InstalledLocation.ToString().Contains("Modules") | Should -Be $true } # It "Install module using -NoClobber, should throw clobber error and not install the module" { # Install-PSResource -Name "ClobberTestModule1" -Repository $PSGalleryName -TrustRepository - - # $res = Get-PSResource "ClobberTestModule1" + + # $res = Get-InstalledPSResource "ClobberTestModule1" # $res.Name | Should -Be "ClobberTestModule1" # Install-PSResource -Name "ClobberTestModule2" -Repository $PSGalleryName -TrustRepository -NoClobber -ErrorAction SilentlyContinue @@ -330,7 +330,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install PSResourceInfo object piped in" { Find-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName | Install-PSResource -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "1.0.0.0" } @@ -346,30 +346,30 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { version = "[1.0.0,5.0.0)" repository = $PSGalleryName } - + test_module2 = @{ version = "[1.0.0,3.0.0)" repository = $PSGalleryName prerelease = "true" } - + TestModule99 = @{ repository = $PSGalleryName } } Install-PSResource -RequiredResource $rrHash -TrustRepository - - $res1 = Get-PSResource $testModuleName + + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - $res2 = Get-PSResource "test_module2" -Version "2.5.0-beta" + $res2 = Get-InstalledPSResource "test_module2" -Version "2.5.0-beta" $res2.Name | Should -Be "test_module2" $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - $res3 = Get-PSResource $testModuleName2 + $res3 = Get-InstalledPSResource $testModuleName2 $res3.Name | Should -Be $testModuleName2 $res3.Version | Should -Be "0.0.93" } @@ -391,17 +391,17 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { }" Install-PSResource -RequiredResource $rrJSON -TrustRepository - - $res1 = Get-PSResource $testModuleName + + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - $res2 = Get-PSResource "test_module2" -Version "2.5.0-beta" + $res2 = Get-InstalledPSResource "test_module2" -Version "2.5.0-beta" $res2.Name | Should -Be "test_module2" $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - $res3 = Get-PSResource $testModuleName2 + $res3 = Get-InstalledPSResource $testModuleName2 $res3.Name | Should -Be $testModuleName2 $res3.Version | Should -Be "0.0.93" } @@ -411,16 +411,16 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { Install-PSResource -RequiredResourceFile $rrFilePSD1 -TrustRepository - $res1 = Get-PSResource $testModuleName + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - $res2 = Get-PSResource "test_module2" -Version "2.5.0-beta" + $res2 = Get-InstalledPSResource "test_module2" -Version "2.5.0-beta" $res2.Name | Should -Be "test_module2" $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - $res3 = Get-PSResource $testModuleName2 + $res3 = Get-InstalledPSResource $testModuleName2 $res3.Name | Should -Be $testModuleName2 $res3.Version | Should -Be "0.0.93" } @@ -430,38 +430,38 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { Install-PSResource -RequiredResourceFile $rrFileJSON -TrustRepository - $res1 = Get-PSResource $testModuleName + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - - $res2 = Get-PSResource "test_module2" -Version "2.5.0-beta" + + $res2 = Get-InstalledPSResource "test_module2" -Version "2.5.0-beta" $res2.Name | Should -Be "test_module2" $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - - $res3 = Get-PSResource $testModuleName2 + + $res3 = Get-InstalledPSResource $testModuleName2 $res3.Name | Should -Be $testModuleName2 $res3.Version | Should -Be "0.0.93" } # Install module 1.4.3 (is authenticode signed and has catalog file) - # Should install successfully + # Should install successfully It "Install modules with catalog file using publisher validation" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $PackageManagement -Version "1.4.3" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource $PackageManagement -Version "1.4.3" + $res1 = Get-InstalledPSResource $PackageManagement -Version "1.4.3" $res1.Name | Should -Be $PackageManagement $res1.Version | Should -Be "1.4.3" } # Install module 1.4.7 (is authenticode signed and has no catalog file) - # Should not install successfully + # Should not install successfully It "Install module with no catalog file" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $PackageManagement -Version "1.4.7" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource $PackageManagement -Version "1.4.7" + $res1 = Get-InstalledPSResource $PackageManagement -Version "1.4.7" $res1.Name | Should -Be $PackageManagement - $res1.Version | Should -Be "1.4.7" + $res1.Version | Should -Be "1.4.7" } # Install module that is not authenticode signed @@ -469,7 +469,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install module that is not authenticode signed" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $testModuleName -Version "5.0.0" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" } # # Install 1.4.4.1 (with incorrect catalog file) @@ -479,11 +479,11 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { # } # Install script that is signed - # Should install successfully + # Should install successfully It "Install script that is authenticode signed" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name "Install-VSCode" -Version "1.4.2" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource "Install-VSCode" -Version "1.4.2" + $res1 = Get-InstalledPSResource "Install-VSCode" -Version "1.4.2" $res1.Name | Should -Be "Install-VSCode" $res1.Version | Should -Be "1.4.2" } @@ -493,7 +493,7 @@ Describe 'Test Install-PSResource for V2 Server scenarios' -tags 'CI' { It "Install script that is not signed" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" } } @@ -521,15 +521,15 @@ Describe 'Test Install-PSResource for interactive and root user scenarios' { It "Install resource under AllUsers scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name "TestModule" -Repository $TestGalleryName -Scope AllUsers $pkg = Get-Module "TestModule" -ListAvailable - $pkg.Name | Should -Be "TestModule" + $pkg.Name | Should -Be "TestModule" $pkg.Path.Contains("/usr/") | Should -Be $true } # This needs to be manually tested due to prompt It "Install resource that requires accept license without -AcceptLicense flag" { Install-PSResource -Name "testModuleWithlicense" -Repository $TestGalleryName - $pkg = Get-PSResource "testModuleWithlicense" - $pkg.Name | Should -Be "testModuleWithlicense" + $pkg = Get-InstalledPSResource "testModuleWithlicense" + $pkg.Name | Should -Be "testModuleWithlicense" $pkg.Version | Should -Be "0.0.1.0" } @@ -538,9 +538,9 @@ Describe 'Test Install-PSResource for interactive and root user scenarios' { Set-PSResourceRepository PoshTestGallery -Trusted:$false Install-PSResource -Name "TestModule" -Repository $TestGalleryName -confirm:$false - + $pkg = Get-Module "TestModule" -ListAvailable - $pkg.Name | Should -Be "TestModule" + $pkg.Name | Should -Be "TestModule" Set-PSResourceRepository PoshTestGallery -Trusted } diff --git a/test/InstallPSResourceTests/InstallPSResourceV3Server.Tests.ps1 b/test/InstallPSResourceTests/InstallPSResourceV3Server.Tests.ps1 index d8dba9d64..175aaf0d9 100644 --- a/test/InstallPSResourceTests/InstallPSResourceV3Server.Tests.ps1 +++ b/test/InstallPSResourceTests/InstallPSResourceV3Server.Tests.ps1 @@ -45,58 +45,58 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { It "Install specific module resource by name" { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" } It "Install specific script resource by name" { Install-PSResource -Name $testScriptName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testScriptName + $pkg = Get-InstalledPSResource $testScriptName $pkg.Name | Should -Be $testScriptName $pkg.Version | Should -Be "3.5.0" } It "Install multiple resources by name" { $pkgNames = @($testModuleName, $testModuleName2) - Install-PSResource -Name $pkgNames -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $pkgNames + Install-PSResource -Name $pkgNames -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $pkgNames $pkg.Name | Should -Be $pkgNames } It "Should not install resource given nonexistant name" { Install-PSResource -Name "NonExistantModule" -Repository $NuGetGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue - $pkg = Get-PSResource "NonExistantModule" + $pkg = Get-InstalledPSResource "NonExistantModule" $pkg.Name | Should -BeNullOrEmpty $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" + $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" } # Do some version testing, but Find-PSResource should be doing thorough testing It "Should install resource given name and exact version" { Install-PSResource -Name $testModuleName -Version "1.0.0" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "1.0.0" } It "Should install resource given name and exact version with bracket syntax" { - Install-PSResource -Name $testModuleName -Version "[1.0.0]" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "[1.0.0]" -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "1.0.0" } It "Should install resource given name and exact range inclusive [1.0.0, 5.0.0]" { - Install-PSResource -Name $testModuleName -Version "[1.0.0, 5.0.0]" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "[1.0.0, 5.0.0]" -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" } It "Should install resource given name and exact range exclusive (1.0.0, 5.0.0)" { - Install-PSResource -Name $testModuleName -Version "(1.0.0, 5.0.0)" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Version "(1.0.0, 5.0.0)" -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "3.0.0" } @@ -111,42 +111,42 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { {} $Error[0].FullyQualifiedErrorId | Should -be "IncorrectVersionFormat,Microsoft.PowerShell.PowerShellGet.Cmdlets.InstallPSResource" - $res = Get-PSResource $testModuleName + $res = Get-InstalledPSResource $testModuleName $res | Should -BeNullOrEmpty } It "Install resource when given Name, Version '*', should install the latest version" { Install-PSResource -Name $testModuleName -Version "*" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" } It "Install resource with latest (including prerelease) version given Prerelease parameter" { - Install-PSResource -Name $testModuleName -Prerelease -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Prerelease -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.2.5" $pkg.Prerelease | Should -Be "alpha001" } It "Install resource via InputObject by piping from Find-PSresource" { - Find-PSResource -Name $testModuleName -Repository $NuGetGalleryName | Install-PSResource -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + Find-PSResource -Name $testModuleName -Repository $NuGetGalleryName | Install-PSResource -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" } It "Install resource under specified in PSModulePath" { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName - $pkg.Name | Should -Be $testModuleName + $pkg = Get-InstalledPSResource $testModuleName + $pkg.Name | Should -Be $testModuleName ($env:PSModulePath).Contains($pkg.InstalledLocation) } It "Install resource with companyname, copyright and repository source location and validate properties" { Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Version | Should -Be "5.2.5" $pkg.Prerelease | Should -Be "alpha001" @@ -158,7 +158,7 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { # Windows only It "Install resource under CurrentUser scope - Windows only" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -173,8 +173,8 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { # Windows only It "Install resource under no specified scope - Windows only" -Skip:(!(Get-IsWindows)) { - Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("Documents") | Should -Be $true } @@ -183,7 +183,7 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under CurrentUser scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository -Scope CurrentUser - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } @@ -192,14 +192,14 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { # Expected path should be similar to: '/home/janelane/.local/share/powershell/Modules' It "Install resource under no specified scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.InstalledLocation.ToString().Contains("$env:HOME/.local") | Should -Be $true } It "Should not install resource that is already installed" { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository -WarningVariable WarningVar -warningaction SilentlyContinue $WarningVar | Should -Not -BeNullOrEmpty @@ -207,18 +207,18 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { It "Reinstall resource that is already installed with -Reinstall parameter" { Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -Reinstall -TrustRepository - $pkg = Get-PSResource $testModuleName + $pkg = Get-InstalledPSResource $testModuleName $pkg.Name | Should -Be $testModuleName $pkg.Version | Should -Be "5.0.0" } # It "Restore resource after reinstall fails" { # Install-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - # $pkg = Get-PSResource $testModuleName + # $pkg = Get-InstalledPSResource $testModuleName # $pkg.Name | Should -Contain $testModuleName # $pkg.Version | Should -Contain "5.0.0" @@ -244,14 +244,14 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { # It "Install resource that requires accept license with -AcceptLicense flag" { # Install-PSResource -Name "testModuleWithlicense" -Repository $TestGalleryName -AcceptLicense - # $pkg = Get-PSResource "testModuleWithlicense" - # $pkg.Name | Should -Be "testModuleWithlicense" + # $pkg = Get-InstalledPSResource "testModuleWithlicense" + # $pkg.Name | Should -Be "testModuleWithlicense" # $pkg.Version | Should -Be "0.0.3.0" # } It "Install PSResourceInfo object piped in" { Find-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName | Install-PSResource -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $res.Name | Should -Be $testModuleName $res.Version | Should -Be "1.0.0" } @@ -267,29 +267,29 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { version = "[1.0.0,5.0.0)" repository = $NuGetGalleryName } - + test_module2 = @{ version = "[1.0.0,5.0.0]" repository = $NuGetGalleryName prerelease = "true" } - + TestModule99 = @{ repository = $NuGetGalleryName } } Install-PSResource -RequiredResource $rrHash -TrustRepository - - $res1 = Get-PSResource $testModuleName + + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0" - $res2 = Get-PSResource $testModuleName2 + $res2 = Get-InstalledPSResource $testModuleName2 $res2.Name | Should -Be $testModuleName2 $res2.Version | Should -Be "5.0.0" - $res3 = Get-PSResource "TestModule99" + $res3 = Get-InstalledPSResource "TestModule99" $res3.Name | Should -Be "TestModule99" $res3.Version | Should -Be "0.0.93" } @@ -311,16 +311,16 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { }" Install-PSResource -RequiredResource $rrJSON -TrustRepository - - $res1 = Get-PSResource $testModuleName + + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0" - $res2 = Get-PSResource $testModuleName2 + $res2 = Get-InstalledPSResource $testModuleName2 $res2.Name | Should -Be $testModuleName2 $res2.Version | Should -Be "5.0.0.0" - $res3 = Get-PSResource "testModule99" + $res3 = Get-InstalledPSResource "testModule99" $res3.Name | Should -Be "testModule99" $res3.Version | Should -Be "0.0.93" } @@ -330,16 +330,16 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { Install-PSResource -RequiredResourceFile $rrFilePSD1 -TrustRepository - $res1 = Get-PSResource $testModuleName + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - $res2 = Get-PSResource $testModuleName2 -Version "2.5.0-beta" + $res2 = Get-InstalledPSResource $testModuleName2 -Version "2.5.0-beta" $res2.Name | Should -Be $testModuleName2 $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - $res3 = Get-PSResource "testModule99" + $res3 = Get-InstalledPSResource "testModule99" $res3.Name | Should -Be "testModule99" $res3.Version | Should -Be "0.0.93" } @@ -349,16 +349,16 @@ Describe 'Test Install-PSResource for V3Server scenarios' -tags 'CI' { Install-PSResource -RequiredResourceFile $rrFileJSON -TrustRepository - $res1 = Get-PSResource $testModuleName + $res1 = Get-InstalledPSResource $testModuleName $res1.Name | Should -Be $testModuleName $res1.Version | Should -Be "3.0.0.0" - - $res2 = Get-PSResource $testModuleName2 -Version "2.5.0-beta" + + $res2 = Get-InstalledPSResource $testModuleName2 -Version "2.5.0-beta" $res2.Name | Should -Be $testModuleName2 $res2.Version | Should -Be "2.5.0" $res2.Prerelease | Should -Be "beta" - - $res3 = Get-PSResource "testModule99" + + $res3 = Get-InstalledPSResource "testModule99" $res3.Name | Should -Be "testModule99" $res3.Version | Should -Be "0.0.93" } @@ -387,15 +387,15 @@ Describe 'Test Install-PSResource for interactive and root user scenarios' { It "Install resource under AllUsers scope - Unix only" -Skip:(Get-IsWindows) { Install-PSResource -Name "TestModule" -Repository $TestGalleryName -Scope AllUsers $pkg = Get-Module "TestModule" -ListAvailable - $pkg.Name | Should -Be "TestModule" + $pkg.Name | Should -Be "TestModule" $pkg.Path.Contains("/usr/") | Should -Be $true } # This needs to be manually tested due to prompt It "Install resource that requires accept license without -AcceptLicense flag" { Install-PSResource -Name "testModuleWithlicense" -Repository $TestGalleryName - $pkg = Get-PSResource "testModuleWithlicense" - $pkg.Name | Should -Be "testModuleWithlicense" + $pkg = Get-InstalledPSResource "testModuleWithlicense" + $pkg.Name | Should -Be "testModuleWithlicense" $pkg.Version | Should -Be "0.0.1.0" } @@ -404,9 +404,9 @@ Describe 'Test Install-PSResource for interactive and root user scenarios' { Set-PSResourceRepository PoshTestGallery -Trusted:$false Install-PSResource -Name "TestModule" -Repository $TestGalleryName -confirm:$false - + $pkg = Get-Module "TestModule" -ListAvailable - $pkg.Name | Should -Be "TestModule" + $pkg.Name | Should -Be "TestModule" Set-PSResourceRepository PoshTestGallery -Trusted } diff --git a/test/NewPSScriptFileInfo.Tests.ps1 b/test/NewPSScriptFile.Tests.ps1 similarity index 76% rename from test/NewPSScriptFileInfo.Tests.ps1 rename to test/NewPSScriptFile.Tests.ps1 index 6cae5e9dc..3cb017d73 100644 --- a/test/NewPSScriptFileInfo.Tests.ps1 +++ b/test/NewPSScriptFile.Tests.ps1 @@ -3,7 +3,7 @@ Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force -Describe "Test New-PSScriptFileInfo" -Tags 'CI' { +Describe "Test New-PSScriptFile" -Tags 'CI' { BeforeAll { $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1" $tmpDirPaths = @($tmpDir1Path) @@ -20,10 +20,10 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { } } - It "Create .ps1 file with minimal required fields" { + It "Create .ps1 file with minimal required fields" { $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Description $description - Test-PSScriptFileInfo -Path $script:testScriptFilePath | Should -BeTrue + New-PSScriptFile -Path $script:testScriptFilePath -Description $description + Test-PSScriptFile -Path $script:testScriptFilePath | Should -BeTrue } It "Create .ps1 file with relative path" { @@ -31,9 +31,9 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:PSScriptInfoName.ps1" $description = "Test description" - New-PSScriptFileInfo -Path $scriptFilePath -Description $description + New-PSScriptFile -Path $scriptFilePath -Description $description - Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue + Test-PSScriptFile -Path $scriptFilePath | Should -BeTrue Remove-Item -Path $scriptFilePath } @@ -41,7 +41,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $version = "2.0.0.0" $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Version $version -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Version $version -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -53,7 +53,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $guid = [guid]::NewGuid() $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Guid $guid -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Guid $guid -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -62,10 +62,10 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { } It "Create new .ps1 given Author parameter" { - $author = "Test Author" + $author = "Test Author" $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Author $author -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Author $author -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -76,7 +76,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { It "Create new .ps1 given Description parameter" { $description = "PowerShellGet test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -88,7 +88,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $companyName = "Microsoft" $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -CompanyName $companyName -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -CompanyName $companyName -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -100,7 +100,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $copyright = "(c) Test Corporation" $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Copyright $copyright -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Copyright $copyright -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -113,9 +113,9 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $requiredModuleVersion = '1.0.0.0' $RequiredModules = @(@{ModuleName = $requiredModuleName; ModuleVersion = $requiredModuleVersion }) - $description = "Test description" + $description = "Test description" - New-PSScriptFileInfo -Path $script:testScriptFilePath -RequiredModules $RequiredModules -Description $Description + New-PSScriptFile -Path $script:testScriptFilePath -RequiredModules $RequiredModules -Description $Description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -128,7 +128,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $description = "Test Description" $releaseNotes = "Release notes for script." - New-PSScriptFileInfo -Path $script:testScriptFilePath -ReleaseNotes $releaseNotes -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -ReleaseNotes $releaseNotes -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -141,7 +141,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $tag1 = "tag1" $tag2 = "tag2" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Tags $tag1, $tag2 -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -Tags $tag1, $tag2 -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -154,7 +154,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $description = "Test Description" $projectUri = "https://www.testprojecturi.com/" - New-PSScriptFileInfo -Path $script:testScriptFilePath -ProjectUri $projectUri -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -ProjectUri $projectUri -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -166,7 +166,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $description = "Test Description" $licenseUri = "https://www.testlicenseuri.com/" - New-PSScriptFileInfo -Path $script:testScriptFilePath -LicenseUri $licenseUri -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -LicenseUri $licenseUri -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -178,7 +178,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $description = "Test Description" $iconUri = "https://www.testiconuri.com/" - New-PSScriptFileInfo -Path $script:testScriptFilePath -IconUri $iconUri -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -IconUri $iconUri -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -191,7 +191,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $externalModuleDep1 = "ExternalModuleDep1" $externalModuleDep2 = "ExternalModuleDep2" - New-PSScriptFileInfo -Path $script:testScriptFilePath -ExternalModuleDependencies $externalModuleDep1, $externalModuleDep2 -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -ExternalModuleDependencies $externalModuleDep1, $externalModuleDep2 -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -205,7 +205,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $requiredScript1 = "RequiredScript1" $requiredScript2 = "RequiredScript2" - New-PSScriptFileInfo -Path $script:testScriptFilePath -RequiredScripts $requiredScript1, $requiredScript2 -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -RequiredScripts $requiredScript1, $requiredScript2 -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -219,7 +219,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { $externalScriptDep1 = "ExternalScriptDep1" $externalScriptDep2 = "ExternalScriptDep2" - New-PSScriptFileInfo -Path $script:testScriptFilePath -ExternalScriptDependencies $externalScriptDep1, $externalScriptDep2 -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -ExternalScriptDependencies $externalScriptDep1, $externalScriptDep2 -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -231,7 +231,7 @@ Describe "Test New-PSScriptFileInfo" -Tags 'CI' { It "Create new .ps1 given PrivateData parameter" { $description = "Test Description" $privateData = @{"PrivateDataEntry1" = "PrivateDataValue1"} - New-PSScriptFileInfo -Path $script:testScriptFilePath -PrivateData $privateData -Description $description + New-PSScriptFile -Path $script:testScriptFilePath -PrivateData $privateData -Description $description Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw diff --git a/test/TestPSScriptFileInfo.Tests.ps1 b/test/TestPSScriptFile.Tests.ps1 similarity index 78% rename from test/TestPSScriptFileInfo.Tests.ps1 rename to test/TestPSScriptFile.Tests.ps1 index fcd010f99..f83cff1b9 100644 --- a/test/TestPSScriptFileInfo.Tests.ps1 +++ b/test/TestPSScriptFile.Tests.ps1 @@ -3,7 +3,7 @@ Import-Module "$psscriptroot\PSGetTestUtils.psm1" -Force -Describe "Test Test-PSScriptFileInfo" -Tags 'CI' { +Describe "Test Test-PSScriptFile" -Tags 'CI' { BeforeAll { $tmpDir1Path = Join-Path -Path $TestDrive -ChildPath "tmpDir1" $tmpDirPaths = @($tmpDir1Path) @@ -16,59 +16,59 @@ Describe "Test Test-PSScriptFileInfo" -Tags 'CI' { $script:testScriptsFolderPath = Join-Path $testFilesFolderPath -ChildPath "testScripts" } - It "determine script file with minimal required fields as valid" { + It "determine script file with minimal required fields as valid" { $scriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "testscript.ps1" $scriptDescription = "this is a test script" - New-PSScriptFileInfo -Path $scriptFilePath -Description $scriptDescription - Test-PSScriptFileInfo $scriptFilePath | Should -Be $true + New-PSScriptFile -Path $scriptFilePath -Description $scriptDescription + Test-PSScriptFile $scriptFilePath | Should -Be $true } It "not determine script file with Author field missing as valid" { $scriptName = "InvalidScriptMissingAuthor.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $false + Test-PSScriptFile $scriptFilePath | Should -Be $false } It "not determine script file with Description field missing as valid" { $scriptName = "InvalidScriptMissingDescription.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $false + Test-PSScriptFile $scriptFilePath | Should -Be $false } It "not determine script that is missing Description block altogether as valid" { $scriptName = "InvalidScriptMissingDescriptionCommentBlock.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $false + Test-PSScriptFile $scriptFilePath | Should -Be $false } It "not determine script file Guid as valid" { $scriptName = "InvalidScriptMissingGuid.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $false + Test-PSScriptFile $scriptFilePath | Should -Be $false } It "not determine script file missing Version as valid" { $scriptName = "InvalidScriptMissingVersion.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $false + Test-PSScriptFile $scriptFilePath | Should -Be $false } It "determine script without empty lines in PSScriptInfo comment content is valid" { $scriptName = "ScriptWithoutEmptyLinesInMetadata.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $true + Test-PSScriptFile $scriptFilePath | Should -Be $true } It "determine script without empty lines between comment blocks is valid" { $scriptName = "ScriptWithoutEmptyLinesBetweenCommentBlocks.ps1" $scriptFilePath = Join-Path $script:testScriptsFolderPath -ChildPath $scriptName - Test-PSScriptFileInfo $scriptFilePath | Should -Be $true + Test-PSScriptFile $scriptFilePath | Should -Be $true } } diff --git a/test/UninstallPSResource.Tests.ps1 b/test/UninstallPSResource.Tests.ps1 index 75b1a244f..b18d10ad0 100644 --- a/test/UninstallPSResource.Tests.ps1 +++ b/test/UninstallPSResource.Tests.ps1 @@ -29,7 +29,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { It "Uninstall a specific module by name" { Uninstall-PSResource -name $testModuleName - Get-PSResource $testModuleName | Should -BeNullOrEmpty + Get-InstalledPSResource $testModuleName | Should -BeNullOrEmpty } $testCases = @{Name="Test?Module"; ErrorId="ErrorFilteringNamesForUnsupportedWildcards"}, @@ -45,31 +45,31 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { It "Uninstall a list of modules by name" { $null = Install-PSResource "testmodule99" -Repository $PSGalleryName -TrustRepository -WarningAction SilentlyContinue -SkipDependencyCheck - Uninstall-PSResource -Name $testModuleName, "testmodule99" - Get-PSResource $testModuleName, "testmodule99" | Should -BeNullOrEmpty + Uninstall-PSResource -Name $testModuleName, "testmodule99" + Get-InstalledPSResource $testModuleName, "testmodule99" | Should -BeNullOrEmpty } It "Uninstall a specific script by name" { $null = Install-PSResource $testScriptName -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testScriptName + $res = Get-InstalledPSResource -Name $testScriptName $res.Name | Should -Be $testScriptName Uninstall-PSResource -Name $testScriptName - $res = Get-PSResource -Name $testScriptName + $res = Get-InstalledPSResource -Name $testScriptName $res | Should -BeNullOrEmpty } It "Uninstall a list of scripts by name" { $null = Install-PSResource $testScriptName, "Required-Script1" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testScriptName + $res = Get-InstalledPSResource -Name $testScriptName $res.Name | Should -Be $testScriptName - $res2 = Get-PSResource -Name "Required-Script1" + $res2 = Get-InstalledPSResource -Name "Required-Script1" $res2.Name | Should -Be "Required-Script1" Uninstall-PSResource -Name $testScriptName, "Required-Script1" - $res = Get-PSResource -Name $testScriptName + $res = Get-InstalledPSResource -Name $testScriptName $res | Should -BeNullOrEmpty - $res2 = Get-PSResource -Name "Required-Script1" + $res2 = Get-InstalledPSResource -Name "Required-Script1" $res2 | Should -BeNullOrEmpty } @@ -79,7 +79,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "5.0.0" -TrustRepository -WarningAction SilentlyContinue Uninstall-PSResource -Name $testModuleName -version "*" - $pkgs = Get-PSResource $testModuleName + $pkgs = Get-InstalledPSResource $testModuleName $pkgs.Version | Should -Not -Contain "1.0.0" $pkgs.Version | Should -Not -Contain "3.0.0" $pkgs.Version | Should -Not -Contain "5.0.0" @@ -91,7 +91,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "5.0.0" -TrustRepository -WarningAction SilentlyContinue Uninstall-PSResource -Name $testModuleName - $pkgs = Get-PSResource $testModuleName + $pkgs = Get-InstalledPSResource $testModuleName $pkgs.Version | Should -Not -Contain "1.0.0" $pkgs.Version | Should -Not -Contain "3.0.0" $pkgs.Version | Should -Not -Contain "5.0.0" @@ -103,7 +103,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "5.0.0" -TrustRepository -WarningAction SilentlyContinue Uninstall-PSResource -Name $testModuleName -Version "3.0.0" - $pkgs = Get-PSResource -Name $testModuleName + $pkgs = Get-InstalledPSResource -Name $testModuleName $pkgs.Version | Should -Not -Contain "1.0.0" } @@ -116,7 +116,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { @{Version="(,3.0.0.0)"; ExpectedVersion="1.0.0.0"; Reason="validate version, maximum version exclusive"}, @{Version="(,3.0.0.0]"; ExpectedVersion="1.0.0.0"; Reason="validate version, maximum version inclusive"}, @{Version="[1.0.0.0, 5.0.0.0)"; ExpectedVersion="3.0.0.0"; Reason="validate version, mixed inclusive minimum and exclusive maximum version"} - + It "Uninstall module when given Name to " -TestCases $testCases { param($Version, $ExpectedVersion) Uninstall-PSResource -Name $testModuleName -Version "*" @@ -125,7 +125,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { $null = Install-PSResource $testModuleName -Repository $PSGalleryName -Version "5.0.0" -TrustRepository -WarningAction SilentlyContinue Uninstall-PSResource -Name $testModuleName -Version $Version - $pkgs = Get-PSResource $testModuleName + $pkgs = Get-InstalledPSResource $testModuleName $pkgs.Version | Should -Not -Contain $Version } @@ -157,14 +157,14 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { } catch {} - $pkg = Get-PSResource $testModuleName -Version "1.0.0.0" + $pkg = Get-InstalledPSResource $testModuleName -Version "1.0.0.0" $pkg.Version | Should -Be "1.0.0.0" } It "Uninstall prerelease version module when prerelease version specified" { Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName -TrustRepository Uninstall-PSResource -Name $testModuleName -Version "5.2.5-alpha001" - $res = Get-PSResource $testModuleName -Version "5.2.5-alpha001" + $res = Get-InstalledPSResource $testModuleName -Version "5.2.5-alpha001" $res | Should -BeNullOrEmpty } @@ -173,7 +173,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { # despite the core version part being the same this uninstall on a nonexistant prerelease version should not be successful Install-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository Uninstall-PSResource -Name $testModuleName -Version "5.0.0-preview" -ErrorAction SilentlyContinue - $res = Get-PSResource -Name $testModuleName -Version "5.0.0.0" + $res = Get-InstalledPSResource -Name $testModuleName -Version "5.0.0.0" $res.Name | Should -Be $testModuleName $res.Version | Should -Be "5.0.0.0" } @@ -181,14 +181,14 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { It "Uninstall prerelease version script when prerelease version specified" { Install-PSResource -Name $testScriptName -Version "3.0.0-alpha" -Repository $PSGalleryName -TrustRepository Uninstall-PSResource -Name $testScriptName -Version "3.0.0-alpha" - $res = Get-PSResource -Name $testScriptName + $res = Get-InstalledPSResource -Name $testScriptName $res | Should -BeNullOrEmpty } It "Not uninstall non-prerelease version module when prerelease version specified" { Install-PSResource -Name $testScriptName -Version "2.5.0.0" -Repository $PSGalleryName -TrustRepository Uninstall-PSResource -Name $testScriptName -Version "2.5.0-alpha001" -ErrorAction SilentlyContinue - $res = Get-PSResource -Name $testScriptName -Version "2.5.0.0" + $res = Get-InstalledPSResource -Name $testScriptName -Version "2.5.0.0" $res.Name | Should -Be $testScriptName $res.Version | Should -Be "2.5" } @@ -199,12 +199,12 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "3.0.0" -Repository $PSGalleryName -TrustRepository Install-PSResource -Name $testModuleName -Version "5.0.0" -Repository $PSGalleryName -TrustRepository Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $prereleaseVersionPkgs = $res | Where-Object {$_.IsPrerelease -eq $true} $prereleaseVersionPkgs.Count | Should -Be 2 Uninstall-PSResource -Name $testModuleName -Version "*" -Prerelease - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $prereleaseVersionPkgs = $res | Where-Object {$_.IsPrerelease -eq $true} $prereleaseVersionPkgs.Count | Should -Be 0 $stableVersionPkgs = $res | Where-Object {$_.IsPrerelease -ne $true} @@ -218,12 +218,12 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "5.0.0" -Repository $PSGalleryName -TrustRepository Install-PSResource -Name $testModuleName -Version "5.2.5-alpha001" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $prereleaseVersionPkgs = $res | Where-Object {$_.IsPrerelease -eq $true} $prereleaseVersionPkgs.Count | Should -Be 2 Uninstall-PSResource -Name $testModuleName -Version "[2.0.0, 5.0.0]" -Prerelease - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName # should only uninstall 2.5.0-beta, 5.2.5-alpha001 is out of range and should remain installed $prereleaseVersionPkgs = $res | Where-Object {$_.IsPrerelease -eq $true} $prereleaseVersionPkgs.Count | Should -Be 1 @@ -234,16 +234,16 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { It "Uninstall module using -WhatIf, should not uninstall the module" { Uninstall-PSResource -Name $testModuleName -WhatIf - $pkg = Get-PSResource $testModuleName -Version "5.0.0.0" + $pkg = Get-InstalledPSResource $testModuleName -Version "5.0.0.0" $pkg.Version | Should -Be "5.0.0.0" } It "Do not Uninstall module that is a dependency for another module" { $null = Install-PSResource "test_module" -Repository $PSGalleryName -TrustRepository -WarningAction SilentlyContinue - + Uninstall-PSResource -Name "RequiredModule1" -ErrorVariable ev -ErrorAction SilentlyContinue - $pkg = Get-PSResource "RequiredModule1" + $pkg = Get-InstalledPSResource "RequiredModule1" $pkg | Should -Not -Be $null $ev.FullyQualifiedErrorId | Should -BeExactly 'UninstallPSResourcePackageIsaDependency,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource', 'UninstallResourceError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource' @@ -253,25 +253,25 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { $null = Install-PSResource $testModuleName -Repository $PSGalleryName -TrustRepository -WarningAction SilentlyContinue Uninstall-PSResource -Name "RequiredModule1" -SkipDependencyCheck - - $pkg = Get-PSResource "RequiredModule1" + + $pkg = Get-InstalledPSResource "RequiredModule1" $pkg | Should -BeNullOrEmpty } It "Uninstall PSResourceInfo object piped in" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository - Get-PSResource -Name $testModuleName -Version "1.0.0.0" | Uninstall-PSResource - $res = Get-PSResource -Name "ContosoServer" -Version "1.0.0.0" + Get-InstalledPSResource -Name $testModuleName -Version "1.0.0.0" | Uninstall-PSResource + $res = Get-InstalledPSResource -Name "ContosoServer" -Version "1.0.0.0" $res | Should -BeNullOrEmpty } It "Uninstall PSResourceInfo object piped in for prerelease version object" { Install-PSResource -Name $testModuleName -Version "2.5.0-beta" -Repository $PSGalleryName -TrustRepository - Get-PSResource -Name $testModuleName -Version "2.5.0-beta" | Uninstall-PSResource - $res = Get-PSResource -Name $testModuleName -Version "2.5.0-beta" + Get-InstalledPSResource -Name $testModuleName -Version "2.5.0-beta" | Uninstall-PSResource + $res = Get-InstalledPSResource -Name $testModuleName -Version "2.5.0-beta" $res | Should -BeNullOrEmpty } - + It "Uninstall module that is not installed should throw error" { Uninstall-PSResource -Name "NonInstalledModule" -ErrorVariable ev -ErrorAction SilentlyContinue $ev.FullyQualifiedErrorId | Should -BeExactly 'UninstallResourceError,Microsoft.PowerShell.PowerShellGet.Cmdlets.UninstallPSResource' @@ -280,8 +280,8 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { # Windows only It "Uninstall resource under CurrentUser scope only- Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) { Install-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers -Reinstall - Uninstall-PSResource -Name $testModuleName -Scope CurrentUser - + Uninstall-PSResource -Name $testModuleName -Scope CurrentUser + $pkg = Get-Module $testModuleName -ListAvailable $pkg.Name | Should -Be $testModuleName $pkg.Path.ToString().Contains("Program Files") | Should -Be $true @@ -290,7 +290,7 @@ Describe 'Test Uninstall-PSResource for Modules' -tags 'CI' { # Windows only It "Uninstall resource under AllUsers scope only- Windows only" -Skip:(!((Get-IsWindows) -and (Test-IsAdmin))) { Install-PSResource $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers -Reinstall - Uninstall-PSResource -Name $testModuleName -Scope AllUsers + Uninstall-PSResource -Name $testModuleName -Scope AllUsers $pkg = Get-Module $testModuleName -ListAvailable $pkg.Name | Should -Be $testModuleName diff --git a/test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 index 444d5433c..b16f93dfa 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceLocalTests.ps1 @@ -31,9 +31,9 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { It "Update resource installed given Name parameter" { Install-PSResource -Name $moduleName -Version "1.0.0" -Repository $localRepo -TrustRepository - + Update-PSResource -Name $moduleName -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -52,7 +52,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Install-PSResource -Name $moduleName2 -Version "1.0.0" -Repository $localRepo -TrustRepository Update-PSResource -Name "test_local*" -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name "test_local*" -Version "5.0.0" + $res = Get-InstalledPSResource -Name "test_local*" -Version "5.0.0" $inputHashtable = @{test_module = "1.0.0"; test_module2 = "1.0.0"} $isTest_ModuleUpdated = $false @@ -80,7 +80,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Install-PSResource -Name $moduleName -Version "1.0.0" -Repository $localRepo -TrustRepository Update-PSResource -Name $moduleName -Version "5.0.0" -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) { @@ -93,7 +93,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { $isPkgUpdated | Should -BeTrue } - # Windows only + # Windows only It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { # TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too Install-PSResource -Name $moduleName -Version "1.0.0.0" -Repository $localRepo -TrustRepository -Scope AllUsers @@ -101,7 +101,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Update-PSResource -Name $moduleName -Version "3.0.0.0" -Repository $localRepo -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -115,7 +115,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { $isPkgUpdated | Should -Be $true } - + # Windows only It "update resource under AllUsers scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { Install-PSResource -Name $moduleName -Version "1.0.0" -Repository $localRepo -TrustRepository -Scope AllUsers @@ -144,7 +144,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Install-PSResource -Name $moduleName -Version "1.0.0.0" -Repository $localRepo -TrustRepository Update-PSResource -Name $moduleName -Version "5.0.0.0" -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -168,7 +168,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Update-PSResource -Name $moduleName -Repository $localRepo -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -191,7 +191,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Update-PSResource -Name $moduleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -215,7 +215,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Update-PSResource -Name $moduleName -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -233,7 +233,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { # It "update resource that requires accept license with -AcceptLicense flag" { # Install-PSResource -Name "TestModuleWithLicense" -Version "0.0.1.0" -Repository $TestGalleryName -AcceptLicense # Update-PSResource -Name "TestModuleWithLicense" -Repository $TestGalleryName -AcceptLicense - # $res = Get-PSResource "TestModuleWithLicense" + # $res = Get-InstalledPSResource "TestModuleWithLicense" # $isPkgUpdated = $false # foreach ($pkg in $res) @@ -251,7 +251,7 @@ Describe 'Test Update-PSResource for local repositories' -tags 'CI' { Install-PSResource -Name $moduleName -Version "1.0.0.0" -Repository $localRepo -TrustRepository Update-PSResource -Name $moduleName -WhatIf -Repository $localRepo -TrustRepository - $res = Get-PSResource -Name $moduleName + $res = Get-InstalledPSResource -Name $moduleName $isPkgUpdated = $false foreach ($pkg in $res) diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 index 2110d80ba..756b72095 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV2Tests.ps1 @@ -27,9 +27,9 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { It "Update resource installed given Name parameter" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository - + Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -48,7 +48,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName2 -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name "test_mod*" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name "test_mod*" -Version "5.0.0.0" + $res = Get-InstalledPSResource -Name "test_mod*" -Version "5.0.0.0" $inputHashtable = @{test_module = "1.0.0.0"; test_module2 = "1.0.0.0"} $isTest_ModuleUpdated = $false @@ -76,7 +76,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) { @@ -120,7 +120,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version $Version -Repository $PSGalleryName -TrustRepository 2>$null - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) { @@ -136,7 +136,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { It "Update resource with latest (including prerelease) version given Prerelease parameter" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Prerelease -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -151,7 +151,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $isPkgUpdated | Should -Be $true } - # Windows only + # Windows only It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { # TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope AllUsers @@ -159,7 +159,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Version "3.0.0.0" -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -173,7 +173,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { $isPkgUpdated | Should -Be $true } - + # Windows only It "update resource under AllUsers scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { Install-PSResource -Name "testmodule99" -Version "0.0.91" -Repository $PSGalleryName -TrustRepository -Scope AllUsers @@ -191,7 +191,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version "3.0.0.0" -Repository $PSGalleryName -TrustRepository -verbose - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -215,7 +215,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -239,7 +239,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -263,7 +263,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -281,7 +281,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { # It "update resource that requires accept license with -AcceptLicense flag" { # Install-PSResource -Name "TestModuleWithLicense" -Version "0.0.1.0" -Repository $TestGalleryName -AcceptLicense # Update-PSResource -Name "TestModuleWithLicense" -Repository $TestGalleryName -AcceptLicense - # $res = Get-PSResource "TestModuleWithLicense" + # $res = Get-InstalledPSResource "TestModuleWithLicense" # $isPkgUpdated = $false # foreach ($pkg in $res) @@ -299,7 +299,7 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $testModuleName -WhatIf -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -326,9 +326,9 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { # Should update successfully It "Update module with catalog file using publisher validation" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $PackageManagement -Version "1.4.2" -Repository $PSGalleryName -TrustRepository -verbose - Update-PSResource -Name $PackageManagement -Version "1.4.3" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository + Update-PSResource -Name $PackageManagement -Version "1.4.3" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource $PackageManagement -Version "1.4.3" + $res1 = Get-InstalledPSResource $PackageManagement -Version "1.4.3" $res1.Name | Should -Be $PackageManagement $res1.Version | Should -Be "1.4.3" } @@ -339,27 +339,27 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { # Install-PSResource -Name $PackageManagement -Version "1.4.2" -Reinstall -Repository $PSGalleryName -TrustRepository # Update-PSResource -Name $PackageManagement -Version "1.4.4.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue # $err.Count | Should -Not -Be 0 - # $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource" + # $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource" # } # Update to module 1.4.7 (is authenticode signed and has NO catalog file) - # Should update successfully + # Should update successfully It "Install module with no catalog file" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name $PackageManagement -Version "1.4.2" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name $PackageManagement -Version "1.4.7" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource $PackageManagement -Version "1.4.7" + $res1 = Get-InstalledPSResource $PackageManagement -Version "1.4.7" $res1.Name | Should -Be $PackageManagement $res1.Version | Should -Be "1.4.7" } # Update script that is signed - # Should update successfully + # Should update successfully It "Update script that is authenticode signed" -Skip:(!(Get-IsWindows)) { Install-PSResource -Name "Install-VSCode" -Version "1.4.1" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name "Install-VSCode" -Version "1.4.2" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository - $res1 = Get-PSResource "Install-VSCode" -Version "1.4.2" + $res1 = Get-InstalledPSResource "Install-VSCode" -Version "1.4.2" $res1.Name | Should -Be "Install-VSCode" $res1.Version | Should -Be "1.4.2" } @@ -370,6 +370,6 @@ Describe 'Test HTTP Update-PSResource for V2 Server Protocol' -tags 'CI' { Install-PSResource -Name "TestTestScript" -Version "1.0" -Repository $PSGalleryName -TrustRepository Update-PSResource -Name "TestTestScript" -Version "1.3.1.1" -AuthenticodeCheck -Repository $PSGalleryName -TrustRepository -ErrorVariable err -ErrorAction SilentlyContinue $err.Count | Should -Not -Be 0 - $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource" + $err[0].FullyQualifiedErrorId | Should -BeExactly "InstallPackageFailure,Microsoft.PowerShell.PowerShellGet.Cmdlets.UpdatePSResource" } } diff --git a/test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 b/test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 index ade468387..70c51b653 100644 --- a/test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 +++ b/test/UpdatePSResourceTests/UpdatePSResourceV3Tests.ps1 @@ -20,9 +20,9 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { It "Update resource installed given Name parameter" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository - + Update-PSResource -Name $testModuleName -Repository $NuGetGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -40,7 +40,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version "5.0.0.0" -Repository $NuGetGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) { @@ -84,7 +84,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version $Version -Repository $NuGetGalleryName -TrustRepository 2>$null - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) { @@ -100,7 +100,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { It "Update resource with latest (including prerelease) version given Prerelease parameter" { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Prerelease -Repository $NuGetGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -115,7 +115,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { $isPkgUpdated | Should -Be $true } - # Windows only + # Windows only It "update resource under CurrentUser scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { # TODO: perhaps also install TestModule with the highest version (the one above 1.2.0.0) to the AllUsers path too Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository -Scope AllUsers @@ -123,7 +123,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Version "3.0.0.0" -Repository $NuGetGalleryName -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -137,7 +137,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { $isPkgUpdated | Should -Be $true } - + # Windows only It "update resource under AllUsers scope" -skip:(!($IsWindows -and (Test-IsAdmin))) { Install-PSResource -Name "testmodule99" -Version "0.0.91" -Repository $NuGetGalleryName -TrustRepository -Scope AllUsers @@ -155,7 +155,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository Update-PSResource -Name $testModuleName -Version "3.0.0.0" -Repository $NuGetGalleryName -TrustRepository -verbose - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -179,7 +179,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope CurrentUser - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -203,7 +203,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository -Scope AllUsers - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -227,7 +227,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Update-PSResource -Name $testModuleName -Repository $PSGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) @@ -245,7 +245,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { # It "update resource that requires accept license with -AcceptLicense flag" { # Install-PSResource -Name "TestModuleWithLicense" -Version "0.0.1.0" -Repository $TestGalleryName -AcceptLicense # Update-PSResource -Name "TestModuleWithLicense" -Repository $TestGalleryName -AcceptLicense - # $res = Get-PSResource "TestModuleWithLicense" + # $res = Get-InstalledPSResource "TestModuleWithLicense" # $isPkgUpdated = $false # foreach ($pkg in $res) @@ -263,7 +263,7 @@ Describe 'Test HTTP Update-PSResource for V3 Server Protocol' -tags 'CI' { Install-PSResource -Name $testModuleName -Version "1.0.0.0" -Repository $NuGetGalleryName -TrustRepository Update-PSResource -Name $testModuleName -WhatIf -Repository $NuGetGalleryName -TrustRepository - $res = Get-PSResource -Name $testModuleName + $res = Get-InstalledPSResource -Name $testModuleName $isPkgUpdated = $false foreach ($pkg in $res) diff --git a/test/UpdatePSScriptFileInfo.Tests.ps1 b/test/UpdatePSScriptFileInfo.Tests.ps1 index 028867c72..2e0ec704c 100644 --- a/test/UpdatePSScriptFileInfo.Tests.ps1 +++ b/test/UpdatePSScriptFileInfo.Tests.ps1 @@ -22,7 +22,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $script:psScriptInfoName = "test_script" $scriptDescription = "this is a test script" $script:testScriptFilePath = Join-Path -Path $tmpDir1Path -ChildPath "$script:psScriptInfoName.ps1" - New-PSScriptFileInfo -Path $script:testScriptFilePath -Description $scriptDescription + New-PSScriptFile -Path $script:testScriptFilePath -Description $scriptDescription } AfterEach { @@ -37,10 +37,10 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:psScriptInfoName.ps1" $oldDescription = "Old description for test script" $newDescription = "New description for test script" - New-PSScriptFileInfo -Path $scriptFilePath -Description $oldDescription - + New-PSScriptFile -Path $scriptFilePath -Description $oldDescription + Update-PSScriptFileInfo -Path $scriptFilePath -Description $newDescription - Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue + Test-PSScriptFile -Path $scriptFilePath | Should -BeTrue Test-Path -Path $scriptFilePath | Should -BeTrue $results = Get-Content -Path $scriptFilePath -Raw @@ -60,10 +60,10 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $relativeCurrentPath = Get-Location $scriptFilePath = Join-Path -Path $relativeCurrentPath -ChildPath "$script:psScriptInfoName.ps1" - New-PSScriptFileInfo -Path $scriptFilePath -Description $description -Version $version -Author $author -ProjectUri $projectUri + New-PSScriptFile -Path $scriptFilePath -Description $description -Version $version -Author $author -ProjectUri $projectUri Update-PSScriptFileInfo -Path $scriptFilePath -Author $newAuthor - Test-PSScriptFileInfo -Path $scriptFilePath | Should -BeTrue + Test-PSScriptFile -Path $scriptFilePath | Should -BeTrue $results = Get-Content -Path $scriptFilePath -Raw $results.Contains($newAuthor) | Should -BeTrue $results.Contains(".AUTHOR $newAuthor") | Should -BeTrue @@ -81,10 +81,10 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { Remove-Item -Path $scriptFilePath -Force } - It "update script file Author property" { + It "update script file Author property" { $author = "New Author" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Author $author - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -95,7 +95,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file Version property" { $version = "2.0.0.0" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Version $version - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -106,7 +106,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file Version property with prerelease version" { $version = "3.0.0-alpha" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Version $version - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -123,7 +123,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file Description property" { $description = "this is an updated test script" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Description $description - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -134,7 +134,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file Guid property" { $guid = [Guid]::NewGuid(); Update-PSScriptFileInfo -Path $script:testScriptFilePath -Guid $guid - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -145,7 +145,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file CompanyName property" { $companyName = "New Corporation" Update-PSScriptFileInfo -Path $script:testScriptFilePath -CompanyName $companyName - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -156,7 +156,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file Copyright property" { $copyright = "(c) 2022 New Corporation. All rights reserved" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Copyright $copyright - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -168,20 +168,20 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $externalModuleDep1 = "ExternalModuleDep1" $externalModuleDep2 = "ExternalModuleDep2" Update-PSScriptFileInfo -Path $script:testScriptFilePath -ExternalModuleDependencies $externalModuleDep1,$externalModuleDep2 - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw $results.Contains($externalModuleDep1) | Should -BeTrue $results.Contains($externalModuleDep2) | Should -BeTrue - $results -like "*.EXTERNALMODULEDEPENDENCIES*$externalModuleDep1*$externalModuleDep2*" | Should -BeTrue + $results -like "*.EXTERNALMODULEDEPENDENCIES*$externalModuleDep1*$externalModuleDep2*" | Should -BeTrue } It "update script file ExternalScriptDependencies property" { $externalScriptDep1 = "ExternalScriptDep1" $externalScriptDep2 = "ExternalScriptDep2" Update-PSScriptFileInfo -Path $script:testScriptFilePath -ExternalScriptDependencies $externalScriptDep1,$externalScriptDep2 - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -193,7 +193,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file IconUri property" { $iconUri = "https://testscript.com/icon" Update-PSScriptFileInfo -Path $script:testScriptFilePath -IconUri $iconUri - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -204,7 +204,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file LicenseUri property" { $licenseUri = "https://testscript.com/license" Update-PSScriptFileInfo -Path $script:testScriptFilePath -LicenseUri $licenseUri - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -215,7 +215,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file ProjectUri property" { $projectUri = "https://testscript.com/" Update-PSScriptFileInfo -Path $script:testScriptFilePath -ProjectUri $projectUri - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -226,7 +226,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file PrivateData property" { $privateData = "this is some private data" Update-PSScriptFileInfo -Path $script:testScriptFilePath -PrivateData $privateData - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -237,7 +237,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { It "update script file ReleaseNotes property" { $releaseNotes = "Release notes for script." Update-PSScriptFileInfo -Path $script:testScriptFilePath -ReleaseNotes $releaseNotes - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -250,10 +250,10 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $hashtable2 = @{ModuleName = "RequiredModule2"; ModuleVersion = "1.0.0.0"} $hashtable3 = @{ModuleName = "RequiredModule3"; RequiredVersion = "2.5.0.0"} $hashtable4 = @{ModuleName = "RequiredModule4"; ModuleVersion = "1.1.0.0"; MaximumVersion = "2.0.0.0"} - $requiredModules = $hashtable1, $hashtable2, $hashtable3, $hashtable4 + $requiredModules = $hashtable1, $hashtable2, $hashtable3, $hashtable4 Update-PSScriptFileInfo -Path $script:testScriptFilePath -RequiredModules $requiredModules - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -265,7 +265,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $requiredScript1 = "RequiredScript1" $requiredScript2 = "RequiredScript2" Update-PSScriptFileInfo -Path $script:testScriptFilePath -RequiredScripts $requiredScript1, $requiredScript2 - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -278,7 +278,7 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $tag1 = "tag1" $tag2 = "tag2" Update-PSScriptFileInfo -Path $script:testScriptFilePath -Tags $tag1, $tag2 - Test-PSScriptFileInfo $script:testScriptFilePath | Should -Be $true + Test-PSScriptFile $script:testScriptFilePath | Should -Be $true Test-Path -Path $script:testScriptFilePath | Should -BeTrue $results = Get-Content -Path $script:testScriptFilePath -Raw @@ -309,6 +309,6 @@ Describe "Test Update-PSScriptFileInfo" -Tags 'CI' { $tmpScriptFilePath = Join-Path -Path $TestDrive -ChildPath $scriptName Update-PSScriptFileInfo -Path $tmpScriptFilePath -Version "2.0.0.0" -RemoveSignature - Test-PSScriptFileInfo -Path $tmpScriptFilePath | Should -Be $true + Test-PSScriptFile -Path $tmpScriptFilePath | Should -Be $true } }