@@ -46,6 +46,44 @@ Describe "Test Compress-PSResource" -tags 'CI' {
4646 BeforeAll {
4747 Get-NewPSResourceRepositoryFile
4848
49+ $testDir = (get-item $psscriptroot ).parent.FullName
50+
51+ function CreateTestModule
52+ {
53+ param (
54+ [string ] $Path = " $TestDrive " ,
55+ [string ] $ModuleName = ' TestModule'
56+ )
57+
58+ $modulePath = Join-Path - Path $Path - ChildPath $ModuleName
59+ $moduleMan = Join-Path $modulePath - ChildPath ($ModuleName + ' .psd1' )
60+ $moduleSrc = Join-Path $modulePath - ChildPath ($ModuleName + ' .psm1' )
61+
62+ if ( Test-Path - Path $modulePath ) {
63+ Remove-Item - Path $modulePath - Recurse - Force
64+ }
65+
66+ $null = New-Item - Path $modulePath - ItemType Directory - Force
67+
68+ @'
69+ @{{
70+ RootModule = "{0}.psm1"
71+ ModuleVersion = '1.0.0'
72+ Author = 'None'
73+ Description = 'None'
74+ GUID = '0c2829fc-b165-4d72-9038-ae3a71a755c1'
75+ FunctionsToExport = @('Test1')
76+ RequiredModules = @('NonExistentModule')
77+ }}
78+ '@ -f $ModuleName | Out-File - FilePath $moduleMan
79+
80+ @'
81+ function Test1 {
82+ Write-Output 'Hello from Test1'
83+ }
84+ '@ | Out-File - FilePath $moduleSrc
85+ }
86+
4987 # Register temporary repositories
5088 $tmpRepoPath = Join-Path - Path $TestDrive - ChildPath " tmpRepoPath"
5189 New-Item $tmpRepoPath - Itemtype directory - Force
@@ -154,14 +192,17 @@ Describe "Test Compress-PSResource" -tags 'CI' {
154192 Test-Path - Path (Join-Path - Path $unzippedPath - ChildPath $testFile ) | Should - Be $True
155193 }
156194
157- It " Compress-PSResource -PassThru returns the path to the nupkg " {
195+ It " Compress-PSResource -PassThru returns a FileInfo object with the correct path " {
158196 $version = " 1.0.0"
159197 New-ModuleManifest - Path (Join-Path - Path $script :PublishModuleBase - ChildPath " $script :PublishModuleName .psd1" ) - ModuleVersion $version - Description " $script :PublishModuleName module"
160198
161- $nupkgPath = Compress-PSResource - Path $script :PublishModuleBase - DestinationPath $script :repositoryPath - PassThru
199+ $fileInfoObject = Compress-PSResource - Path $script :PublishModuleBase - DestinationPath $script :repositoryPath - PassThru
162200
163201 $expectedPath = Join-Path - Path $script :repositoryPath - ChildPath " $script :PublishModuleName .$version .nupkg"
164- $nupkgPath | Should - Be $expectedPath
202+ $fileInfoObject | Should - BeOfType ' System.IO.FileSystemInfo'
203+ $fileInfoObject.FullName | Should - Be $expectedPath
204+ $fileInfoObject.Extension | Should - Be ' .nupkg'
205+ $fileInfoObject.Name | Should - Be " $script :PublishModuleName .$version .nupkg"
165206 }
166207
167208<# Test for Signing the nupkg. Signing doesn't work
0 commit comments