Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4541bae

Browse files
Fixed a typo in one and added 2 more tests
1 parent bf07fca commit 4541bae

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

‎tests/Invoke-DbaDiagnosticQuery.Tests.ps1

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
88
$script:PesterOutputPath = "TestDrive:$commandName"
99
$database = "dbatoolsci_frk_$(Get-Random)"
1010
$database2 = "dbatoolsci_frk_$(Get-Random)"
11+
$database3 = "dbatoolsci_frk_$(Get-Random)"
1112
$server = Connect-DbaInstance -SqlInstance $script:instance2
1213
$server.Query("CREATE DATABASE [$database]")
1314
$server.Query("CREATE DATABASE [$database2]")
15+
$server.Query("CREATE DATABASE [$database3]")
1416
}
1517
AfterAll {
16-
@($database, $database2) | Foreach-Object {
18+
@($database, $database2,$database3) | Foreach-Object {
1719
$db = $_
1820
$server.Query("IF DB_ID('$db') IS NOT NULL
1921
begin
@@ -38,11 +40,26 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
3840
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -DatabaseSpecific
3941
@($results).Count | Should -BeGreaterThan 10
4042
}
43+
It "works with specific database provided" {
44+
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'File Sizes and Space', 'Log Space Usage' -Database $database2, $database3
45+
@($results | Where-Object {$_.Database -eq $Database}).Count | Should -Be 0
46+
@($results | Where-Object {$_.Database -eq $Database2}).Count | Should -Be 2
47+
@($results | Where-Object {$_.Database -eq $Database3}).Count | Should -Be 2
48+
}
4149
It "works with Exclude Databases provided" {
4250
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -DatabaseSpecific -ExcludeDatabase $database2
43-
@($results | Where-Object {$_.Database -eq $Database1}).Count | Should -BeGreaterThan 1
51+
@($results | Where-Object {$_.Database -eq $Database}).Count | Should -BeGreaterThan 1
4452
@($results | Where-Object {$_.Database -eq $Database2}).Count | Should -Be 0
4553
}
54+
55+
$columnnames = 'Item', 'RowError', 'RowState', 'Table', 'ItemArray', 'HasErrors'
56+
$TestCases = @()
57+
$columnnames.ForEach{$TestCases += @{columnname = $PSItem}}
58+
$results = Invoke-DbaDiagnosticQuery -SqlInstance $script:instance2 -QueryName 'Memory Clerk Usage'
59+
It "correctly excludes default column name <columnname>" -TestCases $TestCases {
60+
Param($columnname)
61+
@($results.Result | Get-Member | Where-Object Name -eq $columnname).Count | Should be 0
62+
}
4663
}
4764

4865
context "verifying output when exporting queries as files instead of running" {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /