@@ -8,12 +8,14 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
8
8
$script :PesterOutputPath = " TestDrive:$commandName "
9
9
$database = " dbatoolsci_frk_$ ( Get-Random ) "
10
10
$database2 = " dbatoolsci_frk_$ ( Get-Random ) "
11
+ $database3 = " dbatoolsci_frk_$ ( Get-Random ) "
11
12
$server = Connect-DbaInstance - SqlInstance $script :instance2
12
13
$server.Query (" CREATE DATABASE [$database ]" )
13
14
$server.Query (" CREATE DATABASE [$database2 ]" )
15
+ $server.Query (" CREATE DATABASE [$database3 ]" )
14
16
}
15
17
AfterAll {
16
- @ ($database , $database2 ) | Foreach-Object {
18
+ @ ($database , $database2 , $database3 ) | Foreach-Object {
17
19
$db = $_
18
20
$server.Query (" IF DB_ID('$db ') IS NOT NULL
19
21
begin
@@ -38,11 +40,26 @@ Describe "$CommandName Integration Tests" -Tags "IntegrationTests" {
38
40
$results = Invoke-DbaDiagnosticQuery - SqlInstance $script :instance2 - DatabaseSpecific
39
41
@ ($results ).Count | Should - BeGreaterThan 10
40
42
}
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
+ }
41
49
It " works with Exclude Databases provided" {
42
50
$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
44
52
@ ($results | Where-Object {$_.Database -eq $Database2 }).Count | Should - Be 0
45
53
}
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
+ }
46
63
}
47
64
48
65
context " verifying output when exporting queries as files instead of running" {
0 commit comments