Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/Get-DbaDbQueryStoreOption.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ Describe $CommandName -Tag IntegrationTests {

Context "When a system database is named explicitly" {
It "Warns about master and tempdb instead of silently returning nothing" {
$resultsSystemDb = Get-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceSingle -Database master, tempdb -WarningVariable warnSystemDb
$resultsSystemDb = Get-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceSingle -Database master, tempdb -WarningVariable warnSystemDb -WarningAction SilentlyContinue
$resultsSystemDb | Should -BeNullOrEmpty
$warnSystemDb -join "`n" | Should -Match "Query Store cannot be enabled on system database master"
$warnSystemDb -join "`n" | Should -Match "Query Store cannot be enabled on system database tempdb"
}

It "Reads model from SQL Server 2022 on and warns about it before that" {
$resultsModel = Get-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceSingle -Database model -WarningVariable warnModel
# Silenced because the pre-2022 branch below expects a warning. The warning is still
# captured in $warnModel, so an unexpected one on 2022 and later fails the assertion.
$resultsModel = Get-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceSingle -Database model -WarningVariable warnModel -WarningAction SilentlyContinue

if ($serverSingle.VersionMajor -ge 16) {
$resultsModel.Database | Should -Be "model"
Expand Down
4 changes: 2 additions & 2 deletions tests/Set-DbaDbQueryStoreOption.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Describe $CommandName -Tag IntegrationTests {
}

It "Warns about master and tempdb instead of doing nothing at all" {
$resultsSystemDb = Set-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceMulti1 -Database master, tempdb -State ReadWrite -WarningVariable warnSystemDb
$resultsSystemDb = Set-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceMulti1 -Database master, tempdb -State ReadWrite -WarningVariable warnSystemDb -WarningAction SilentlyContinue
$resultsSystemDb | Should -BeNullOrEmpty
$warnSystemDb -join "`n" | Should -Match "Query Store cannot be enabled on system database master"
$warnSystemDb -join "`n" | Should -Match "Query Store cannot be enabled on system database tempdb"
Expand All @@ -138,7 +138,7 @@ Describe $CommandName -Tag IntegrationTests {
$null = Set-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceMulti1 -Database model -StaleQueryThreshold $originalThreshold
}
} else {
$resultsModel = Set-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceMulti1 -Database model -StaleQueryThreshold 45 -WarningVariable warnModel
$resultsModel = Set-DbaDbQueryStoreOption -SqlInstance $TestConfig.InstanceMulti1 -Database model -StaleQueryThreshold 45 -WarningVariable warnModel -WarningAction SilentlyContinue
$resultsModel | Should -BeNullOrEmpty
$warnModel -join "`n" | Should -Match "Query Store cannot be read on model before SQL Server 2022"
}
Expand Down