From f34b67e4256b9c3a62d0e866fceb7bdd9c2db32a Mon Sep 17 00:00:00 2001 From: nohwnd Date: Sun, 28 Jun 2026 16:27:51 +0200 Subject: [PATCH 1/5] Update Pester release candidate for CI Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/integration-tests-s3.yml | 5 +++++ private/testing/Invoke-ManualPester.ps1 | 8 ++++---- tests/appveyor.pester.ps1 | 4 ++-- tests/appveyor.prep.ps1 | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/integration-tests-s3.yml b/.github/workflows/integration-tests-s3.yml index 088994915ec1..630b6e9dd548 100644 --- a/.github/workflows/integration-tests-s3.yml +++ b/.github/workflows/integration-tests-s3.yml @@ -210,6 +210,11 @@ jobs: sudo update-ca-certificates echo "MinIO certificate added to system trust store" + - name: Install Pester 6 release candidate + run: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Install-Module -Name Pester -RequiredVersion 6.0.0-rc1 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck + - name: Install AWS.Tools.S3 for S3 enumeration tests run: | Write-Host "Installing AWS.Tools.Installer..." diff --git a/private/testing/Invoke-ManualPester.ps1 b/private/testing/Invoke-ManualPester.ps1 index a13615e98bd0..8c1408e4dece 100644 --- a/private/testing/Invoke-ManualPester.ps1 +++ b/private/testing/Invoke-ManualPester.ps1 @@ -168,7 +168,7 @@ function Invoke-ManualPester { $invokeFormatterVersion = (Get-Command Invoke-Formatter -ErrorAction SilentlyContinue).Version $HasScriptAnalyzer = $null -ne $invokeFormatterVersion $MinimumPesterVersion = [Version] '4.0.0.0' # Because this is when -Show was introduced - $MaximumPesterVersion = [Version] '6.0.0.0' # Because we have either pester4 or pester5 tests + $MaximumPesterVersion = [Version] '7.0.0.0' # Because we have either pester4 or pester5+ tests $PesterVersion = (Get-Command Invoke-Pester -ErrorAction SilentlyContinue).Version $HasPester = $null -ne $PesterVersion $ScriptAnalyzerCorrectVersion = '1.18.2' @@ -204,8 +204,8 @@ function Invoke-ManualPester { Write-Warning " or go to https://github.com/pester/Pester" } if ($PesterVersion -gt $MaximumPesterVersion) { - Write-Warning "Please get Pester to the 5.* release" - Write-Warning " Install-Module -Name Pester -MaximumVersion '5.7.1' -Force -SkipPublisherCheck" + Write-Warning "Please get Pester to the 6.0.0 release candidate" + Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc1' -AllowPrerelease -Force -SkipPublisherCheck" Write-Warning " or go to https://github.com/pester/Pester" } @@ -308,7 +308,7 @@ function Invoke-ManualPester { if ($pesterVersionToUse -eq '5') { Write-DetailedMessage "Running Pester 5 tests $($f.Name)" Remove-Module -Name Pester -ErrorAction SilentlyContinue - Import-Module Pester -MinimumVersion 5.7.1 -ErrorAction Stop + Import-Module Pester -RequiredVersion 6.0.0 -ErrorAction Stop $pester5Config = New-PesterConfiguration $pester5Config.Run.Path = $f.FullName if ($PassThru) { diff --git a/tests/appveyor.pester.ps1 b/tests/appveyor.pester.ps1 index 5d8f7c533958..df027643dc26 100644 --- a/tests/appveyor.pester.ps1 +++ b/tests/appveyor.pester.ps1 @@ -386,8 +386,8 @@ if (-not $Finalize) { # Remove any previously loaded pester module Remove-Module -Name Pester -ErrorAction SilentlyContinue - # Import pester 5 - Import-Module -Name Pester -RequiredVersion 5.7.1 + # Import Pester 6 release candidate + Import-Module -Name Pester -RequiredVersion 6.0.0 Write-Host -Object "appveyor.pester: Running with Pester Version $((Get-Command Invoke-Pester -ErrorAction SilentlyContinue).Version)" -ForegroundColor DarkGreen # invoking a single invoke-pester consumes too much memory, let's go file by file diff --git a/tests/appveyor.prep.ps1 b/tests/appveyor.prep.ps1 index 0a4ac5493ae1..095e94f5b018 100644 --- a/tests/appveyor.prep.ps1 +++ b/tests/appveyor.prep.ps1 @@ -50,8 +50,8 @@ if ($installedModule.Version.ToString() -notmatch [regex]::Escape($expectedVersi } # Get Pester (to run tests) -Write-Host -Object "appveyor.prep: Install Pester5" -ForegroundColor DarkGreen -Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 5.7.1 +Write-Host -Object "appveyor.prep: Install Pester 6 release candidate" -ForegroundColor DarkGreen +Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc1 -AllowPrerelease # Setup DbatoolsConfig Path.DbatoolsExport path Write-Host -Object "appveyor.prep: Create Path.DbatoolsExport" -ForegroundColor DarkGreen From a7e83708e42d5afbf5a479aabb73df9849efc400 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Mon, 29 Jun 2026 09:54:14 +0200 Subject: [PATCH 2/5] Migrate tests to Pester 6 documented breaking changes Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/integration-tests-s3.yml | 2 +- private/testing/Invoke-ManualPester.ps1 | 2 +- tests/Compare-DbaDbSchema.Tests.ps1 | 2 + tests/Connect-DbaInstance.Tests.ps1 | 3 + tests/Export-DbaCredential.Tests.ps1 | 4 +- tests/Export-DbaLinkedServer.Tests.ps1 | 4 +- tests/Find-DbaInstance.Tests.ps1 | 1 + tests/Get-DbaDatabase.Tests.ps1 | 16 +-- tests/Get-DbaLastBackup.Tests.ps1 | 2 +- tests/Get-DbaNetworkEncryption.Tests.ps1 | 1 + tests/Get-DbaService.Tests.ps1 | 4 +- tests/Install-DbaInstance.Tests.ps1 | 44 ++++----- tests/Invoke-DbaAdvancedInstall.Tests.ps1 | 48 ++++----- tests/Invoke-DbaAdvancedRestore.Tests.ps1 | 1 + tests/Invoke-DbaAdvancedUpdate.Tests.ps1 | 10 +- tests/Invoke-DbaDbDataMasking.Tests.ps1 | 4 +- tests/Invoke-DbaDbShrink.Tests.ps1 | 4 +- tests/New-DbaDatabase.Tests.ps1 | 1 + tests/Set-DbaNetworkCertificate.Tests.ps1 | 2 +- tests/Test-DbaCmConnection.Tests.ps1 | 4 +- tests/Test-DbaDbOwner.Tests.ps1 | 2 +- tests/Test-DbaMaxMemory.Tests.ps1 | 6 +- tests/Update-DbaInstance.Tests.ps1 | 110 ++++++++++----------- tests/appveyor.prep.ps1 | 2 +- 24 files changed, 144 insertions(+), 135 deletions(-) diff --git a/.github/workflows/integration-tests-s3.yml b/.github/workflows/integration-tests-s3.yml index 630b6e9dd548..e7ad50009363 100644 --- a/.github/workflows/integration-tests-s3.yml +++ b/.github/workflows/integration-tests-s3.yml @@ -213,7 +213,7 @@ jobs: - name: Install Pester 6 release candidate run: | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - Install-Module -Name Pester -RequiredVersion 6.0.0-rc1 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck + Install-Module -Name Pester -RequiredVersion 6.0.0-rc2 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck - name: Install AWS.Tools.S3 for S3 enumeration tests run: | diff --git a/private/testing/Invoke-ManualPester.ps1 b/private/testing/Invoke-ManualPester.ps1 index 8c1408e4dece..cfbf753958dd 100644 --- a/private/testing/Invoke-ManualPester.ps1 +++ b/private/testing/Invoke-ManualPester.ps1 @@ -205,7 +205,7 @@ function Invoke-ManualPester { } if ($PesterVersion -gt $MaximumPesterVersion) { Write-Warning "Please get Pester to the 6.0.0 release candidate" - Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc1' -AllowPrerelease -Force -SkipPublisherCheck" + Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc2' -AllowPrerelease -Force -SkipPublisherCheck" Write-Warning " or go to https://github.com/pester/Pester" } diff --git a/tests/Compare-DbaDbSchema.Tests.ps1 b/tests/Compare-DbaDbSchema.Tests.ps1 index 64532ea9942d..1cd837edb499 100644 --- a/tests/Compare-DbaDbSchema.Tests.ps1 +++ b/tests/Compare-DbaDbSchema.Tests.ps1 @@ -106,6 +106,7 @@ Describe $CommandName -Tag UnitTests { $EnableException ) } + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } Mock New-Object { New-MockCompareDbSchemaStartInfo } -ParameterFilter { @@ -178,6 +179,7 @@ Describe $CommandName -Tag UnitTests { $script:capturedVerboseMessages += $Message } } + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } Mock New-Object { New-MockCompareDbSchemaStartInfo } -ParameterFilter { diff --git a/tests/Connect-DbaInstance.Tests.ps1 b/tests/Connect-DbaInstance.Tests.ps1 index 2866aba453e7..97609e703314 100644 --- a/tests/Connect-DbaInstance.Tests.ps1 +++ b/tests/Connect-DbaInstance.Tests.ps1 @@ -101,6 +101,7 @@ Describe $CommandName -Tag UnitTests { } Mock Add-ConnectionHashValue { } -ModuleName dbatools + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } -ModuleName dbatools Mock New-Object { [PSCustomObject]@{ } } -ModuleName dbatools -ParameterFilter { @@ -168,6 +169,7 @@ Describe $CommandName -Tag UnitTests { } Mock Add-ConnectionHashValue { } -ModuleName dbatools + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } -ModuleName dbatools Mock New-Object { [PSCustomObject]@{ ConnectionString = "Data Source=sqltoken;Integrated Security=True" @@ -224,6 +226,7 @@ Describe $CommandName -Tag UnitTests { } Mock Add-ConnectionHashValue { } -ModuleName dbatools + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } -ModuleName dbatools Mock New-Object { $script:lastServerConnection = [PSCustomObject]@{ ConnectionString = $ArgumentList[0].ConnectionString diff --git a/tests/Export-DbaCredential.Tests.ps1 b/tests/Export-DbaCredential.Tests.ps1 index 267c56be4a65..6f4a8250d1b7 100644 --- a/tests/Export-DbaCredential.Tests.ps1 +++ b/tests/Export-DbaCredential.Tests.ps1 @@ -50,7 +50,7 @@ Describe $CommandName -Tag UnitTests { It "Should not force decryption errors to throw by default" { $null = Export-DbaCredential -SqlInstance "sql1" -Passthru - Assert-MockCalled -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { -not $EnableException } } @@ -58,7 +58,7 @@ Describe $CommandName -Tag UnitTests { It "Should request terminating decryption errors when EnableException is specified" { $null = Export-DbaCredential -SqlInstance "sql1" -Passthru -EnableException - Assert-MockCalled -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $EnableException } } diff --git a/tests/Export-DbaLinkedServer.Tests.ps1 b/tests/Export-DbaLinkedServer.Tests.ps1 index 87cdf271a6c8..b2d7334f6078 100644 --- a/tests/Export-DbaLinkedServer.Tests.ps1 +++ b/tests/Export-DbaLinkedServer.Tests.ps1 @@ -56,7 +56,7 @@ Describe $CommandName -Tag UnitTests { It "Should not force decryption errors to throw by default" { $null = Export-DbaLinkedServer -SqlInstance "sql1" -Passthru - Assert-MockCalled -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { -not $EnableException } } @@ -64,7 +64,7 @@ Describe $CommandName -Tag UnitTests { It "Should request terminating decryption errors when EnableException is specified" { $null = Export-DbaLinkedServer -SqlInstance "sql1" -Passthru -EnableException - Assert-MockCalled -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Get-DecryptedObject -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $EnableException } } diff --git a/tests/Find-DbaInstance.Tests.ps1 b/tests/Find-DbaInstance.Tests.ps1 index 7e8f99970141..be7b78bc2f8f 100644 --- a/tests/Find-DbaInstance.Tests.ps1 +++ b/tests/Find-DbaInstance.Tests.ps1 @@ -95,6 +95,7 @@ Describe $CommandName -Tag UnitTests { } function Write-Message { } + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } Mock New-Object { New-MockFindDbaInstanceUdpClient -ResponseBytes $script:browserResponseBytes } -ParameterFilter { diff --git a/tests/Get-DbaDatabase.Tests.ps1 b/tests/Get-DbaDatabase.Tests.ps1 index 8833669ad5d7..ab2889c331c9 100644 --- a/tests/Get-DbaDatabase.Tests.ps1 +++ b/tests/Get-DbaDatabase.Tests.ps1 @@ -178,18 +178,18 @@ Describe $CommandName -Tag UnitTests -Skip { 'CommandName' = 'Stop-Function' 'Times' = 1 'Exactly' = $true - 'Module' = 'dbatools' + 'ModuleName' = 'dbatools' } - Assert-MockCalled @assertMockParams + Should -Invoke @assertMockParams } It "Validates that Test-FunctionInterrupt Mock has been called" { $assertMockParams = @{ 'CommandName' = 'Test-FunctionInterrupt' 'Times' = 1 'Exactly' = $true - 'Module' = 'dbatools' + 'ModuleName' = 'dbatools' } - Assert-MockCalled @assertMockParams + Should -Invoke @assertMockParams } } Context "Output" { @@ -237,18 +237,18 @@ Describe $CommandName -Tag UnitTests -Skip { 'CommandName' = 'Connect-DbaInstance' 'Times' = 2 'Exactly' = $true - 'Module' = 'dbatools' + 'ModuleName' = 'dbatools' } - Assert-MockCalled @assertMockParams + Should -Invoke @assertMockParams } It "Validates that Invoke-QueryDBlastUsed Mock has been called" { $assertMockParams = @{ 'CommandName' = 'Invoke-QueryDBlastUsed' 'Times' = 2 'Exactly' = $true - 'Module' = 'dbatools' + 'ModuleName' = 'dbatools' } - Assert-MockCalled @assertMockParams + Should -Invoke @assertMockParams } } } \ No newline at end of file diff --git a/tests/Get-DbaLastBackup.Tests.ps1 b/tests/Get-DbaLastBackup.Tests.ps1 index 9c077248e998..c8d339530b99 100644 --- a/tests/Get-DbaLastBackup.Tests.ps1 +++ b/tests/Get-DbaLastBackup.Tests.ps1 @@ -50,7 +50,7 @@ Describe $CommandName -Tag UnitTests { $results = @(Get-DbaLastBackup -SqlInstance "sql1" -Database "agdb" -ExcludeReplica) $results | Should -BeNullOrEmpty - Assert-MockCalled -CommandName Get-DbaDbBackupHistory -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-DbaDbBackupHistory -Exactly 0 -Scope It -ModuleName dbatools } } } diff --git a/tests/Get-DbaNetworkEncryption.Tests.ps1 b/tests/Get-DbaNetworkEncryption.Tests.ps1 index 3ede333f5b2a..94cdbad92369 100644 --- a/tests/Get-DbaNetworkEncryption.Tests.ps1 +++ b/tests/Get-DbaNetworkEncryption.Tests.ps1 @@ -183,6 +183,7 @@ Describe $CommandName -Tag UnitTests { $Message ) } + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } Mock New-Object { New-MockNetworkEncryptionUdpClient } -ParameterFilter { diff --git a/tests/Get-DbaService.Tests.ps1 b/tests/Get-DbaService.Tests.ps1 index 0957df087225..746fd3edf2a8 100644 --- a/tests/Get-DbaService.Tests.ps1 +++ b/tests/Get-DbaService.Tests.ps1 @@ -90,8 +90,8 @@ Describe $CommandName -Tag UnitTests { $results | Should -HaveCount 1 $results.ServiceType | Should -Be "PowerBI" - Assert-MockCalled Get-DbaReportingService -Times 1 -Exactly -Scope It - Assert-MockCalled Get-DbaCmObject -Times 0 -Exactly -Scope It -ParameterFilter { $Namespace -eq "root\Microsoft\SQLServer" } + Should -Invoke Get-DbaReportingService -Times 1 -Exactly -Scope It + Should -Invoke Get-DbaCmObject -Times 0 -Exactly -Scope It -ParameterFilter { $Namespace -eq "root\Microsoft\SQLServer" } } } } diff --git a/tests/Install-DbaInstance.Tests.ps1 b/tests/Install-DbaInstance.Tests.ps1 index b4eed9b9b58c..e9079d5130ad 100644 --- a/tests/Install-DbaInstance.Tests.ps1 +++ b/tests/Install-DbaInstance.Tests.ps1 @@ -104,9 +104,9 @@ Describe $CommandName -Tag IntegrationTests { ) | Set-Content -Path TestDrive:\Configuration.ini -Force $result = Install-DbaInstance -Version $version -Path TestDrive: -EnableException -Feature All - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -148,16 +148,16 @@ Describe $CommandName -Tag IntegrationTests { AdminAccount = "local\foo", "local\bar" } $result = Install-DbaInstance @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools if ($version -in "2008", "2008R2", "2012", "2014") { - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools } else { # SQLSVCINSTANTFILEINIT is used for version 2016 and later - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 0 -Scope It -ModuleName dbatools } - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -204,9 +204,9 @@ Describe $CommandName -Tag IntegrationTests { ConfigurationFile = "TestDrive:\Configuration.ini" } $result = Install-DbaInstance @splatConfig -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -237,9 +237,9 @@ Describe $CommandName -Tag IntegrationTests { ) { param($version, $canonicVersion, $mainNode) $result = Install-DbaInstance -Version $version -Path TestDrive: -EnableException -UpdateSourcePath TestDrive: - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -273,10 +273,10 @@ Describe $CommandName -Tag IntegrationTests { Restart = $true } $result = Install-DbaInstance @splatRestart -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -313,9 +313,9 @@ Describe $CommandName -Tag IntegrationTests { Feature = "Tools" } $result = Install-DbaInstance @splatTools -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceSetup -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 3 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.Version | Should -Be $canonicVersion diff --git a/tests/Invoke-DbaAdvancedInstall.Tests.ps1 b/tests/Invoke-DbaAdvancedInstall.Tests.ps1 index 103b73733895..db3c4d57133a 100644 --- a/tests/Invoke-DbaAdvancedInstall.Tests.ps1 +++ b/tests/Invoke-DbaAdvancedInstall.Tests.ps1 @@ -114,10 +114,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -189,10 +189,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -264,10 +264,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -339,10 +339,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -414,10 +414,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* @@ -489,10 +489,10 @@ Describe $CommandName -Tag IntegrationTests { PerformVolumeMaintenanceTasks = $true } $result = Invoke-DbaAdvancedInstall @splatInstall -EnableException - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaPrivilege -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Set-DbaTcpPort -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.ComputerName | Should -BeLike $env:COMPUTERNAME* diff --git a/tests/Invoke-DbaAdvancedRestore.Tests.ps1 b/tests/Invoke-DbaAdvancedRestore.Tests.ps1 index 58cd669448a8..2a25027afb22 100644 --- a/tests/Invoke-DbaAdvancedRestore.Tests.ps1 +++ b/tests/Invoke-DbaAdvancedRestore.Tests.ps1 @@ -111,6 +111,7 @@ Describe $CommandName -Tag UnitTests { BeforeEach { Mock Connect-DbaInstance { $script:mockServer } + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } Mock New-Object { $script:lastRestore = New-MockRestore $script:lastRestore diff --git a/tests/Invoke-DbaAdvancedUpdate.Tests.ps1 b/tests/Invoke-DbaAdvancedUpdate.Tests.ps1 index 6daeb45877c4..08111a7c2144 100644 --- a/tests/Invoke-DbaAdvancedUpdate.Tests.ps1 +++ b/tests/Invoke-DbaAdvancedUpdate.Tests.ps1 @@ -128,11 +128,11 @@ Describe $CommandName -Tag IntegrationTests { Context "Validate upgrades to a latest version" { It "Should mock-upgrade SQL2017\LAB0 to SP0CU12 thinking it's latest" { $result = Invoke-DbaAdvancedUpdate -ComputerName $env:COMPUTERNAME -EnableException -Action $singleAction -ArgumentList @("/foo") - Assert-MockCalled -CommandName Restart-Computer -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Restart-Computer -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { if ($ArgumentList[0] -like "/x:*" -and $ArgumentList[1] -eq "/quiet") { return $true } } - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { if ($ArgumentList -contains "/foo" -and $ArgumentList -contains "/quiet") { return $true } } @@ -148,8 +148,8 @@ Describe $CommandName -Tag IntegrationTests { } It "Should mock-upgrade 2008 to SP3CU7" { $results = Invoke-DbaAdvancedUpdate -ComputerName $env:COMPUTERNAME -Restart $true -EnableException -Action $doubleAction - Assert-MockCalled -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools $results.Count | Should -BeExactly 2 #2008SP3 diff --git a/tests/Invoke-DbaDbDataMasking.Tests.ps1 b/tests/Invoke-DbaDbDataMasking.Tests.ps1 index 185a6e5168ba..e39e44ab14e4 100644 --- a/tests/Invoke-DbaDbDataMasking.Tests.ps1 +++ b/tests/Invoke-DbaDbDataMasking.Tests.ps1 @@ -130,7 +130,7 @@ Describe $CommandName -Tag UnitTests { It "does not prepare unique helper tables when WhatIf is used" { $null = Invoke-DbaDbDataMasking -SqlInstance "sql1" -Database "db1" -FilePath "http://masking-config" -WhatIf - Assert-MockCalled -CommandName Convert-DbaIndexToTable -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Convert-DbaIndexToTable -Exactly 0 -Scope It -ModuleName dbatools } It "uses FilterQuery when counting rows for WhatIf" { @@ -255,7 +255,7 @@ Describe $CommandName -Tag UnitTests { It "uses the filtered row set when building action updates" { $null = Invoke-DbaDbDataMasking -SqlInstance "sql1" -Database "db1" -FilePath "http://masking-config" - Assert-MockCalled -CommandName Invoke-DbaQuery -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Invoke-DbaQuery -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Query.Trim() -eq "UPDATE [dbo].[people] SET [fname] = 'masked' WHERE [PersonId] IN (1);" } } diff --git a/tests/Invoke-DbaDbShrink.Tests.ps1 b/tests/Invoke-DbaDbShrink.Tests.ps1 index 9bf0c0d3ab14..ae728a926bdb 100644 --- a/tests/Invoke-DbaDbShrink.Tests.ps1 +++ b/tests/Invoke-DbaDbShrink.Tests.ps1 @@ -119,7 +119,7 @@ Describe $CommandName -Tag UnitTests { $results[0].Success | Should -Be $false $results[0].Notes | Should -Match "simulated shrink failure" ($script:warningMessages -join " ") | Should -Match "Shrink operation failed for file testdb: .*simulated shrink failure" - Assert-MockCalled -CommandName Stop-Function -Exactly 0 -Scope It + Should -Invoke -CommandName Stop-Function -Exactly 0 -Scope It } It "still uses Stop-Function when EnableException is requested" { @@ -133,7 +133,7 @@ Describe $CommandName -Tag UnitTests { Invoke-DbaDbShrink -InputObject $mockDatabase -FileType Data -ExcludeIndexStats -EnableException } | Should -Throw "*Shrink operation failed for file testdb:*simulated shrink failure*" - Assert-MockCalled -CommandName Stop-Function -Exactly 1 -Scope It + Should -Invoke -CommandName Stop-Function -Exactly 1 -Scope It } } } diff --git a/tests/New-DbaDatabase.Tests.ps1 b/tests/New-DbaDatabase.Tests.ps1 index 5edb65e839fa..29fe885d52e8 100644 --- a/tests/New-DbaDatabase.Tests.ps1 +++ b/tests/New-DbaDatabase.Tests.ps1 @@ -110,6 +110,7 @@ Describe $CommandName -Tag UnitTests { Mock Connect-DbaInstance { $script:mockServer } -ModuleName dbatools Mock Stop-Function { throw $Message } -ModuleName dbatools Mock Test-FunctionInterrupt { $false } -ModuleName dbatools + Mock New-Object { & (Get-Command -Name 'New-Object' -CommandType Cmdlet) @PesterBoundParameters } -ModuleName dbatools Mock New-Object { [PSCustomObject]@{ Name = $ArgumentList[1] diff --git a/tests/Set-DbaNetworkCertificate.Tests.ps1 b/tests/Set-DbaNetworkCertificate.Tests.ps1 index 62e3b11c57f5..103712566cb0 100644 --- a/tests/Set-DbaNetworkCertificate.Tests.ps1 +++ b/tests/Set-DbaNetworkCertificate.Tests.ps1 @@ -68,7 +68,7 @@ Describe $CommandName -Tag UnitTests { $result = Set-DbaNetworkCertificate @splatSetNetworkCertificate $result.CertificateThumbprint | Should -Be $script:certificateThumbprint - Assert-MockCalled -CommandName Restart-DbaService -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Restart-DbaService -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $SqlInstance.FullName -eq "sql1" -and $Credential -eq $script:serviceCredential -and $Type -eq "Engine" -and diff --git a/tests/Test-DbaCmConnection.Tests.ps1 b/tests/Test-DbaCmConnection.Tests.ps1 index bb3d626a3497..c5d46653046e 100644 --- a/tests/Test-DbaCmConnection.Tests.ps1 +++ b/tests/Test-DbaCmConnection.Tests.ps1 @@ -47,8 +47,8 @@ Describe $CommandName -Tag UnitTests { $result.CimWinRMOptions | Should -Not -BeNullOrEmpty $result.CimDCOMOptions | Should -Not -BeNullOrEmpty - Assert-MockCalled New-DbaCimSessionOptionWithTimeout -Exactly 1 -Scope It -ParameterFilter { $Protocol -eq "Default" } - Assert-MockCalled New-DbaCimSessionOptionWithTimeout -Exactly 1 -Scope It -ParameterFilter { $Protocol -eq "Dcom" } + Should -Invoke New-DbaCimSessionOptionWithTimeout -Exactly 1 -Scope It -ParameterFilter { $Protocol -eq "Default" } + Should -Invoke New-DbaCimSessionOptionWithTimeout -Exactly 1 -Scope It -ParameterFilter { $Protocol -eq "Dcom" } } } } diff --git a/tests/Test-DbaDbOwner.Tests.ps1 b/tests/Test-DbaDbOwner.Tests.ps1 index 66d4443a850f..2d5b6b42b08d 100644 --- a/tests/Test-DbaDbOwner.Tests.ps1 +++ b/tests/Test-DbaDbOwner.Tests.ps1 @@ -237,7 +237,7 @@ Describe $CommandName -Tag IntegrationTests { 'Times' = 1 'Exactly' = $true } - Assert-MockCalled @assertMockParams + Should -Invoke @assertMockParams } # it It -Skip "Returns all information with detailed for correct and incorrect owner" { Mock Connect-SQLInstance -MockWith { diff --git a/tests/Test-DbaMaxMemory.Tests.ps1 b/tests/Test-DbaMaxMemory.Tests.ps1 index 5b90a3d71e15..e74c9aebc8c6 100644 --- a/tests/Test-DbaMaxMemory.Tests.ps1 +++ b/tests/Test-DbaMaxMemory.Tests.ps1 @@ -64,9 +64,9 @@ Describe $CommandName -Tag UnitTests { $result = Test-DbaMaxMemory -SqlInstance "ABC" - Assert-MockCalled Connect-DbaInstance -Scope It -Times 1 - Assert-MockCalled Get-DbaService -Scope It -Times 1 - Assert-MockCalled Get-DbaMaxMemory -Scope It -Times 1 + Should -Invoke Connect-DbaInstance -Scope It -Times 1 + Should -Invoke Get-DbaService -Scope It -Times 1 + Should -Invoke Get-DbaMaxMemory -Scope It -Times 1 } It "Connect to SQL Server and retrieve the Max Server Memory setting" { diff --git a/tests/Update-DbaInstance.Tests.ps1 b/tests/Update-DbaInstance.Tests.ps1 index 7e6df2bf218b..b303dffdacdb 100644 --- a/tests/Update-DbaInstance.Tests.ps1 +++ b/tests/Update-DbaInstance.Tests.ps1 @@ -99,23 +99,23 @@ Describe -skip $CommandName -Tag UnitTests { $password = "pwd" | ConvertTo-SecureString -AsPlainText -Force $cred = New-Object PSCredential("usr", $password) $null = Update-DbaInstance -ComputerName "mocked" -Credential $cred -Version "2012SP3" -Path "mocked" -EnableException - Assert-MockCalled -ParameterFilter { $Authentication -eq 'CredSSP' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Initialize-CredSSP -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'CredSSP' } -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -ParameterFilter { $Authentication -eq 'CredSSP' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Initialize-CredSSP -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'CredSSP' } -Exactly 2 -Scope It -ModuleName dbatools } It "should call internal functions using Default" { $null = Update-DbaInstance -ComputerName "mocked" -Version "2012SP3" -Path "mocked" -EnableException - Assert-MockCalled -ParameterFilter { $Authentication -eq 'Default' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Initialize-CredSSP -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'Default' } -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -ParameterFilter { $Authentication -eq 'Default' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Initialize-CredSSP -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'Default' } -Exactly 2 -Scope It -ModuleName dbatools } It "should call internal functions using Kerberos" { $password = "pwd" | ConvertTo-SecureString -AsPlainText -Force $cred = New-Object PSCredential("usr", $password) $null = Update-DbaInstance -ComputerName "mocked" -Authentication Kerberos -Credential $cred -Version "2012SP3" -Path "mocked" -EnableException - Assert-MockCalled -ParameterFilter { $Authentication -eq 'Kerberos' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Initialize-CredSSP -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'Kerberos' } -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -ParameterFilter { $Authentication -eq 'Kerberos' } -CommandName Find-SqlInstanceUpdate -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Initialize-CredSSP -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -ParameterFilter { $Authentication -eq 'Kerberos' } -Exactly 2 -Scope It -ModuleName dbatools } } Context "Validate upgrades to a latest version" { @@ -194,10 +194,10 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade SQL2017\LAB0 to SP0CU12 thinking it's latest" { $result = Update-DbaInstance -Version 2017 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-DbaBuild -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-DbaBuild -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.MajorVersion | Should -Be 2017 @@ -211,10 +211,10 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade SQL2008\LAB2 to latest SP" { $result = Update-DbaInstance -Version 2008 -InstanceName LAB2 -Type ServicePack -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.MajorVersion | Should -Be 2008 @@ -229,12 +229,12 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade SQL2008\LAB2 passing extra command line parameters" { $result = Update-DbaInstance -Version 2008 -InstanceName LAB2 -Type ServicePack -Path $exeDir -ArgumentList @("/foo", "/bar=foobar") -EnableException - Assert-MockCalled -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { if ($ArgumentList[0] -like '/x:*' -and $ArgumentList[1] -eq "/quiet") { return $true } } - Assert-MockCalled -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Invoke-Program -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { if ($ArgumentList -contains "/foo" -and $ArgumentList -contains "/bar=foobar" -and $ArgumentList -contains "/quiet") { return $true } } @@ -250,10 +250,10 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade two versions to latest SPs" { $results = Update-DbaInstance -Version 2008, 2012 -Type ServicePack -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-DbaBuild -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools ($results | Measure-Object).Count | Should -Be 2 @@ -334,9 +334,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade SQL2008 to SP3 (KB2546951)" { $result = Update-DbaInstance -Kb KB2546951 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.MajorVersion | Should -Be 2008 @@ -350,9 +350,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade SQL2016 to SP1CU4 (KB3182545 + KB4024305) " { $result = Update-DbaInstance -Kb 3182545, 4024305 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.MajorVersion | Should -Be 2016 @@ -366,9 +366,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade both versions to different KBs" { $results = Update-DbaInstance -Kb 3182545, 4040714, KB2546951, KB2738350 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 6 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 3 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 6 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 3 -Scope It -ModuleName dbatools ($results | Measure-Object).Count | Should -Be 3 @@ -470,9 +470,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade two SQL2016 servers to SP2" { $results = Update-DbaInstance -ComputerName "localhost", "127.0.0.1" -Version SQL2016SP2 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 4 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 2 -Scope It -ModuleName dbatools foreach ($result in $results) { $result | Should -Not -BeNullOrEmpty @@ -516,9 +516,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should mock-upgrade interrupted setup of SQL2012 SP2" { $result = Update-DbaInstance -Continue -InstanceName LAB -Version 2012SP2 -Path $exeDir -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly 1 -Scope It -ModuleName dbatools $result | Should -Not -BeNullOrEmpty $result.MajorVersion | Should -Be 2012 @@ -563,9 +563,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "Should download and mock-upgrade SQL2012 KB3045321" { $result = Update-DbaInstance -InstanceName LAB -KB KB3045321 -Path $exeDir -Download -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Save-DbaKbUpdate -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly 2 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Save-DbaKbUpdate -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Name -eq '3045321' -and $Path -eq [System.IO.Path]::GetTempPath() -and $Architecture -eq 'x64' } @@ -751,9 +751,9 @@ Describe -skip $CommandName -Tag UnitTests { } It "$v to $cuLevel" { $results = Update-DbaInstance -Version "$v$cuLevel" -Path "mocked" -Restart -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Invoke-Program -Exactly ($steps * 2) -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Restart-Computer -Exactly $steps -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Invoke-Program -Exactly ($steps * 2) -Scope It -ModuleName dbatools + Should -Invoke -CommandName Restart-Computer -Exactly $steps -Scope It -ModuleName dbatools for ($i = 0; $i -lt $steps; $i++) { $result = $results | Select-Object -First 1 -Skip $i $result | Should -Not -BeNullOrEmpty @@ -872,10 +872,10 @@ Describe -Skip "$CommandName Integration Tests" -Tag IntegrationTests { $instance = $server.ServiceName $null = Update-DbaInstance -ComputerName $TestConfig.InstanceSingle -Path $exeDir -Restart -EnableException -WhatIf -InstanceName $instance 3>$null $testBuild = Test-DbaBuild -SqlInstance $server -MaxBehind 0CU - Assert-MockCalled -CommandName Test-PendingReboot -Scope It -ModuleName dbatools - Assert-MockCalled -CommandName Test-ElevationRequirement -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-PendingReboot -Scope It -ModuleName dbatools + Should -Invoke -CommandName Test-ElevationRequirement -Scope It -ModuleName dbatools if ($testBuild.Compliant -eq $false) { - Assert-MockCalled -CommandName Find-SqlInstanceUpdate -Scope It -ModuleName dbatools + Should -Invoke -CommandName Find-SqlInstanceUpdate -Scope It -ModuleName dbatools } } } @@ -937,8 +937,8 @@ Describe "Update-DbaInstance authentication regression" -Tag UnitTests { It "passes Authentication to remote preparation helpers" { $null = Update-DbaInstance -ComputerName "mocked" -Credential $testCredential -Authentication Credssp -Version "2012SP3" -Path "mocked" -EnableException - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Authentication -eq "Credssp" } - Assert-MockCalled -CommandName Test-PendingReboot -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Authentication -eq "Credssp" } + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Authentication -eq "Credssp" } + Should -Invoke -CommandName Test-PendingReboot -Exactly 1 -Scope It -ModuleName dbatools -ParameterFilter { $Authentication -eq "Credssp" } } } @@ -948,7 +948,7 @@ Describe "Update-DbaInstance path validation regression" -Tag UnitTests { { Update-DbaInstance -Version "2012SP3" -Path " " -EnableException } | Should -Throw "*Path is required*" - Assert-MockCalled -CommandName Get-SQLInstanceComponent -Exactly 0 -Scope It -ModuleName dbatools + Should -Invoke -CommandName Get-SQLInstanceComponent -Exactly 0 -Scope It -ModuleName dbatools } } @@ -979,7 +979,7 @@ InModuleScope dbatools { $result = Get-SQLInstanceComponent -ComputerName "mocked" -Credential $testCredential -Authentication Credssp $result | Should -Not -BeNullOrEmpty - Assert-MockCalled -CommandName Invoke-Command2 -Exactly 1 -Scope It -ParameterFilter { $Authentication -eq "Credssp" } + Should -Invoke -CommandName Invoke-Command2 -Exactly 1 -Scope It -ParameterFilter { $Authentication -eq "Credssp" } } It "passes Authentication to Invoke-Command2 without using Get-DbaCmObject for pending reboot checks" { @@ -992,8 +992,8 @@ InModuleScope dbatools { $result = Test-PendingReboot -ComputerName "mocked" -Credential $testCredential -Authentication Credssp $result | Should -BeFalse - Assert-MockCalled -CommandName Invoke-Command2 -Exactly 3 -Scope It -ParameterFilter { $Authentication -eq "Credssp" } - Assert-MockCalled -CommandName Get-DbaCmObject -Exactly 0 -Scope It + Should -Invoke -CommandName Invoke-Command2 -Exactly 3 -Scope It -ParameterFilter { $Authentication -eq "Credssp" } + Should -Invoke -CommandName Get-DbaCmObject -Exactly 0 -Scope It } } } \ No newline at end of file diff --git a/tests/appveyor.prep.ps1 b/tests/appveyor.prep.ps1 index 095e94f5b018..36e7eca77379 100644 --- a/tests/appveyor.prep.ps1 +++ b/tests/appveyor.prep.ps1 @@ -51,7 +51,7 @@ if ($installedModule.Version.ToString() -notmatch [regex]::Escape($expectedVersi # Get Pester (to run tests) Write-Host -Object "appveyor.prep: Install Pester 6 release candidate" -ForegroundColor DarkGreen -Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc1 -AllowPrerelease +Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc2 -AllowPrerelease # Setup DbatoolsConfig Path.DbatoolsExport path Write-Host -Object "appveyor.prep: Create Path.DbatoolsExport" -ForegroundColor DarkGreen From 15c3981b4031b56719ff49c647bf47eb82aad83e Mon Sep 17 00:00:00 2001 From: nohwnd Date: Wed, 1 Jul 2026 09:33:18 +0200 Subject: [PATCH 3/5] Bump Pester to 6.0.0-rc4 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/integration-tests-s3.yml | 2 +- private/testing/Invoke-ManualPester.ps1 | 2 +- tests/appveyor.prep.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests-s3.yml b/.github/workflows/integration-tests-s3.yml index e7ad50009363..fc24b2d4c06e 100644 --- a/.github/workflows/integration-tests-s3.yml +++ b/.github/workflows/integration-tests-s3.yml @@ -213,7 +213,7 @@ jobs: - name: Install Pester 6 release candidate run: | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - Install-Module -Name Pester -RequiredVersion 6.0.0-rc2 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck + Install-Module -Name Pester -RequiredVersion 6.0.0-rc4 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck - name: Install AWS.Tools.S3 for S3 enumeration tests run: | diff --git a/private/testing/Invoke-ManualPester.ps1 b/private/testing/Invoke-ManualPester.ps1 index cfbf753958dd..dcd7b30091a2 100644 --- a/private/testing/Invoke-ManualPester.ps1 +++ b/private/testing/Invoke-ManualPester.ps1 @@ -205,7 +205,7 @@ function Invoke-ManualPester { } if ($PesterVersion -gt $MaximumPesterVersion) { Write-Warning "Please get Pester to the 6.0.0 release candidate" - Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc2' -AllowPrerelease -Force -SkipPublisherCheck" + Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc4' -AllowPrerelease -Force -SkipPublisherCheck" Write-Warning " or go to https://github.com/pester/Pester" } diff --git a/tests/appveyor.prep.ps1 b/tests/appveyor.prep.ps1 index 36e7eca77379..c73372299530 100644 --- a/tests/appveyor.prep.ps1 +++ b/tests/appveyor.prep.ps1 @@ -51,7 +51,7 @@ if ($installedModule.Version.ToString() -notmatch [regex]::Escape($expectedVersi # Get Pester (to run tests) Write-Host -Object "appveyor.prep: Install Pester 6 release candidate" -ForegroundColor DarkGreen -Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc2 -AllowPrerelease +Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc4 -AllowPrerelease # Setup DbatoolsConfig Path.DbatoolsExport path Write-Host -Object "appveyor.prep: Create Path.DbatoolsExport" -ForegroundColor DarkGreen From a3054ec44bd0bcfd0b1e08cc439c52c40e34065d Mon Sep 17 00:00:00 2001 From: nohwnd Date: Thu, 2 Jul 2026 10:22:43 +0200 Subject: [PATCH 4/5] Mock Resolve-DbaNetworkName in Install-DbaInstance tests for Pester 6 Pester 6 (pester/Pester#2654) makes a parameter-filtered Mock throw when no filter matches, instead of silently falling through to the real command. The only parametrized mock in this file covers Get-DbaCmObject for Win32_processor, but Resolve-DbaNetworkName also calls Get-DbaCmObject for win32_ComputerSystem. Under Pester 6 that unmatched call throws; Resolve-DbaNetworkName swallows it, leaving a non-local ComputerName so Install-DbaInstance takes the remote branch (New-PSSession) on AppVeyor and fails with WinRM errors instead of the expected result. Mock Resolve-DbaNetworkName to return the local host, keeping the tests offline and deterministic (matches Update-DbaInstance.Tests.ps1). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/Install-DbaInstance.Tests.ps1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Install-DbaInstance.Tests.ps1 b/tests/Install-DbaInstance.Tests.ps1 index e9079d5130ad..1d18dd8d27ac 100644 --- a/tests/Install-DbaInstance.Tests.ps1 +++ b/tests/Install-DbaInstance.Tests.ps1 @@ -70,6 +70,18 @@ Describe $CommandName -Tag IntegrationTests { Mock -CommandName Set-DbaTcpPort -ModuleName dbatools -MockWith { } Mock -CommandName Restart-DbaService -ModuleName dbatools -MockWith { } Mock -CommandName Get-DbaCmObject -ModuleName dbatools -MockWith { [PSCustomObject]@{ NumberOfLogicalProcessors = 24 } } -ParameterFilter { $ClassName -eq "Win32_processor" } + # Resolve the (local) host without touching the network. Resolve-DbaNetworkName + # internally calls Get-DbaCmObject -ClassName win32_ComputerSystem, which is not + # covered by the Win32_processor mock above; under Pester 6 an unmatched + # parameter-filtered mock throws instead of falling through to the real command, + # so we mock the whole resolver to keep the tests offline and deterministic + # (matches Update-DbaInstance.Tests.ps1). + Mock -CommandName Resolve-DbaNetworkName -ModuleName dbatools -MockWith { + [PSCustomObject]@{ + ComputerName = $env:COMPUTERNAME + FullComputerName = $env:COMPUTERNAME + } + } # mock searching for setup, proper file should always it find Mock -CommandName Find-SqlInstanceSetup -MockWith { Get-ChildItem $Path -Filter "dummy.exe" -ErrorAction Stop | Select-Object -ExpandProperty FullName -First 1 From 5d5da84d1568c8cb0e613fc7cd1bae89db6b56e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Tue, 7 Jul 2026 10:37:09 +0200 Subject: [PATCH 5/5] Update Pester pin to the released 6.0.0 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/integration-tests-s3.yml | 4 ++-- private/testing/Invoke-ManualPester.ps1 | 4 ++-- tests/appveyor.prep.ps1 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration-tests-s3.yml b/.github/workflows/integration-tests-s3.yml index fc24b2d4c06e..1d93c8028d29 100644 --- a/.github/workflows/integration-tests-s3.yml +++ b/.github/workflows/integration-tests-s3.yml @@ -210,10 +210,10 @@ jobs: sudo update-ca-certificates echo "MinIO certificate added to system trust store" - - name: Install Pester 6 release candidate + - name: Install Pester 6 run: | Set-PSRepository -Name PSGallery -InstallationPolicy Trusted - Install-Module -Name Pester -RequiredVersion 6.0.0-rc4 -AllowPrerelease -Force -Scope CurrentUser -SkipPublisherCheck + Install-Module -Name Pester -RequiredVersion 6.0.0 -Force -Scope CurrentUser -SkipPublisherCheck - name: Install AWS.Tools.S3 for S3 enumeration tests run: | diff --git a/private/testing/Invoke-ManualPester.ps1 b/private/testing/Invoke-ManualPester.ps1 index dcd7b30091a2..fd5e8c2e19de 100644 --- a/private/testing/Invoke-ManualPester.ps1 +++ b/private/testing/Invoke-ManualPester.ps1 @@ -204,8 +204,8 @@ function Invoke-ManualPester { Write-Warning " or go to https://github.com/pester/Pester" } if ($PesterVersion -gt $MaximumPesterVersion) { - Write-Warning "Please get Pester to the 6.0.0 release candidate" - Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0-rc4' -AllowPrerelease -Force -SkipPublisherCheck" + Write-Warning "Please get Pester to the 6.0.0 release" + Write-Warning " Install-Module -Name Pester -RequiredVersion '6.0.0' -Force -SkipPublisherCheck" Write-Warning " or go to https://github.com/pester/Pester" } diff --git a/tests/appveyor.prep.ps1 b/tests/appveyor.prep.ps1 index c73372299530..eea096ff9164 100644 --- a/tests/appveyor.prep.ps1 +++ b/tests/appveyor.prep.ps1 @@ -50,8 +50,8 @@ if ($installedModule.Version.ToString() -notmatch [regex]::Escape($expectedVersi } # Get Pester (to run tests) -Write-Host -Object "appveyor.prep: Install Pester 6 release candidate" -ForegroundColor DarkGreen -Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0-rc4 -AllowPrerelease +Write-Host -Object "appveyor.prep: Install Pester 6" -ForegroundColor DarkGreen +Install-Module -Name Pester -Force -SkipPublisherCheck -RequiredVersion 6.0.0 # Setup DbatoolsConfig Path.DbatoolsExport path Write-Host -Object "appveyor.prep: Create Path.DbatoolsExport" -ForegroundColor DarkGreen