Skip to content

Commit

Permalink
Correctly mock the Get-Uft8NoBom function
Browse files Browse the repository at this point in the history
  • Loading branch information
adhilto committed Sep 30, 2024
1 parent ca5ac67 commit bc2cee1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
$OrchestratorPath = '../../../../Modules/Orchestrator.psm1'
$CreateReportPath = '../../../../Modules/CreateReport/CreateReport.psm1'
$UtilityPath = '../../../../Modules/Utility/Utility.psm1'
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath $OrchestratorPath) -Function Invoke-ReportCreation -Force
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath $CreateReportPath) -Function New-Report, Import-SecureBaseline -Force
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath $UtilityPath) -Function Get-Utf8NoBom -Force

InModuleScope Orchestrator {
Describe -Tag 'Orchestrator' -Name 'Invoke-ReportCreation' {
BeforeAll {
Expand All @@ -20,6 +19,7 @@ InModuleScope Orchestrator {
Mock -CommandName Get-Content {}
Mock -CommandName Add-Type {}
Mock -CommandName Invoke-Item {}
function Get-Utf8NoBom {throw 'this will be mocked'}
Mock -CommandName Get-Utf8NoBom {}
Mock -CommandName ConvertFrom-Json { @{ "report_uuid"="" } }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ InModuleScope Orchestrator {
{Invoke-SCuBACached @SplatParams} | Should -Not -Throw
}
It 'Given an existing UUID should not generate a new one' {
# Get-Member was mocked above to return True so the as far as the
# Get-Member was mocked above to return True so as far as the
# provider can tell, the existing output already has a UUID
{Invoke-SCuBACached @SplatParams} | Should -Not -Throw
Should -Invoke -CommandName New-Guid -Exactly -Times 0
}
It 'Given output without a UUID should generate a new one' {
Mock -CommandName Get-Member { $false }
# Now Get-Member will return False so the as far as the
# provider can tell, the existing output does not have a UUID
# Now Get-Member will return False so as far as the provider
# can tell, the existing output does not have a UUID
{Invoke-SCuBACached @SplatParams} | Should -Not -Throw
Should -Invoke -CommandName New-Guid -Exactly -Times 1
}
Expand Down

0 comments on commit bc2cee1

Please sign in to comment.