. $PSScriptRoot\..\..\Load-PesterModules.ps1 $here = Split-Path -Parent $MyInvocation.MyCommand.Path $sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.tests\.', '.' $functionPath = Join-Path -Path $here -ChildPath $sut Write-Host "Overriding SUT: $functionPath" Import-Module $functionPath -Force $moduleForMock = "" Describe "Get-PackageFileListV2" { # subset of actual failing case # Test case should not show any src/ rooted objects, so we are only focusing on non-SDK source code work $script:testString = @" [ { "fullPath": "src/VCU.MS.CardControl.Notifications/", "parentFullPath": "src/", "name": "VCU.MS.CardControl.Notifications", "isDirectory": true }, { "fullPath": "src/", "parentFullPath": "/", "name": "src", "isDirectory": true }, { "fullPath": "src/VCU.MS.CardControl.Notifications/VCU.Modules.CardControl/", "parentFullPath": "src/VCU.MS.CardControl.Notifications/", "name": "VCU.Modules.CardControl", "isDirectory": true }, { "fullPath": "package/services/metadata/core-properties/", "parentFullPath": "package/services/metadata/", "name": "core-properties", "isDirectory": true }, { "fullPath": "package/services/metadata/", "parentFullPath": "package/services/", "name": "metadata", "isDirectory": true }, { "fullPath": "package/services/", "parentFullPath": "package/", "name": "services", "isDirectory": true }, { "fullPath": "package/", "parentFullPath": "/", "name": "package", "isDirectory": true }, { "fullPath": "package/services/metadata/core-properties/5bb485eb5b744639ac99ff7821cf325a.psmdcp", "parentFullPath": "package/services/metadata/core-properties/", "name": "5bb485eb5b744639ac99ff7821cf325a.psmdcp", "isDirectory": false }, { "fullPath": "src/VCU.MS.CardControl.Notifications/VCU.Modules.CardControl/AlkamiManifest.xml", "parentFullPath": "src/VCU.MS.CardControl.Notifications/VCU.Modules.CardControl/", "name": "AlkamiManifest.xml", "isDirectory": false }, { "fullPath": "_rels/", "parentFullPath": "/", "name": "_rels", "isDirectory": true }, { "fullPath": "_rels/.rels", "parentFullPath": "_rels/", "name": ".rels", "isDirectory": false }, { "fullPath": "tools/", "parentFullPath": "/", "name": "tools", "isDirectory": true }, { "fullPath": "tools/VCU.MS.CardControl.Notifications.Host.exe", "parentFullPath": "tools/", "name": "VCU.MS.CardControl.Notifications.Host.exe", "isDirectory": false }, { "fullPath": "tools/ChocolateyUninstall.ps1", "parentFullPath": "tools/", "name": "ChocolateyUninstall.ps1", "isDirectory": false }, { "fullPath": "tools/ChocolateyInstall.ps1", "parentFullPath": "tools/", "name": "ChocolateyInstall.ps1", "isDirectory": false }, { "fullPath": "VCU.MS.CardControl.Notifications.Host.nuspec", "parentFullPath": "/", "name": "VCU.MS.CardControl.Notifications.Host.nuspec", "isDirectory": false }, { "fullPath": "[Content_Types].xml", "parentFullPath": "/", "name": "[Content_Types].xml", "isDirectory": false } ] "@ Mock -Module $moduleForMock -CommandName Invoke-ProgetRequest -MockWith { return $script:testString } Mock -Module $moduleForMock -CommandName Get-BasicAuthHeader -MockWith { return @{} } # just give an empty object for parameter Mock -Module $moduleForMock -CommandName Write-Host -MockWith { } Context "It does not throw when called with valid parameters" { It "Does not throw" { {Get-PackageFileListV2 -FeedSource "https://magic.feed/nuget/magic.feed" -Name "ignored" -Version "ignored" } | Should -Not -Throw } } Context "No /src records returned" { $FileList = (Get-PackageFileListV2 -FeedSource "https://magic.feed/nuget/magic.feed" -Name "ignored" -Version "ignored") It "No record exists with name = AlkamiManifest.xml" { $FileList.Where({$_.name -eq 'AlkamiManifest.xml'}) | Should -BeNull } It "Definitely has a source record with name = AlkamiManifest.xml tho" { (ConvertFrom-Json $script:testString).Where({$_.name -eq 'AlkamiManifest.xml'}) | Should -Not -BeNull } } }