@@ -154,6 +154,57 @@ Describe "Test Compress-PSResource" -tags 'CI' {
154154 Test-Path - Path (Join-Path - Path $unzippedPath - ChildPath $testFile ) | Should - Be $True
155155 }
156156
157+ It " Compresses a script" {
158+ $scriptName = " PSGetTestScript"
159+ $scriptVersion = " 1.0.0"
160+
161+ $params = @ {
162+ Version = $scriptVersion
163+ GUID = [guid ]::NewGuid()
164+ Author = ' Jane'
165+ CompanyName = ' Microsoft Corporation'
166+ Copyright = ' (c) 2020 Microsoft Corporation. All rights reserved.'
167+ Description = " Description for the $scriptName script"
168+ LicenseUri = " https://$scriptName .com/license"
169+ IconUri = " https://$scriptName .com/icon"
170+ ProjectUri = " https://$scriptName .com"
171+ Tags = @ (' Tag1' , ' Tag2' , " Tag-$scriptName -$scriptVersion " )
172+ ReleaseNotes = " $scriptName release notes"
173+ }
174+
175+ $scriptPath = (Join-Path - Path $script :tmpScriptsFolderPath - ChildPath " $scriptName .ps1" )
176+ New-PSScriptFileInfo @params - Path $scriptPath
177+
178+ Compress-PSResource - Path $scriptPath - DestinationPath $script :repositoryPath
179+
180+ $expectedPath = Join-Path - Path $script :repositoryPath - ChildPath " $scriptName .$scriptVersion .nupkg"
181+ (Get-ChildItem $script :repositoryPath ).FullName | Should - Be $expectedPath
182+ }
183+
184+ It " Compress-PSResource -DestinationPath works for relative paths" {
185+ $version = " 1.0.0"
186+ $relativePath = " .\RelativeTestModule"
187+ $relativeDestination = " .\RelativeDestination"
188+
189+ # Create relative paths
190+ New-Item - Path $relativePath - ItemType Directory - Force
191+ New-Item - Path $relativeDestination - ItemType Directory - Force
192+
193+ # Create module manifest in the relative path
194+ New-ModuleManifest - Path (Join-Path - Path $relativePath - ChildPath " $script :PublishModuleName .psd1" ) - ModuleVersion $version - Description " $script :PublishModuleName module"
195+
196+ # Compress using relative paths
197+ Compress-PSResource - Path $relativePath - DestinationPath $relativeDestination
198+
199+ $expectedPath = Join-Path - Path $relativeDestination - ChildPath " $script :PublishModuleName .$version .nupkg"
200+ $fileExists = Test-Path - Path $expectedPath
201+ $fileExists | Should - Be $True
202+
203+ # Cleanup
204+ Remove-Item - Path $relativePath - Recurse - Force
205+ Remove-Item - Path $relativeDestination - Recurse - Force
206+ }
207+
157208 It " Compress-PSResource -PassThru returns a FileInfo object with the correct path" {
158209 $version = " 1.0.0"
159210 New-ModuleManifest - Path (Join-Path - Path $script :PublishModuleBase - ChildPath " $script :PublishModuleName .psd1" ) - ModuleVersion $version - Description " $script :PublishModuleName module"
0 commit comments