-
-
Notifications
You must be signed in to change notification settings - Fork 831
/
Copy pathClear-DbaPlanCache.Tests.ps1
53 lines (47 loc) · 1.76 KB
/
Clear-DbaPlanCache.Tests.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#Requires -Module @{ ModuleName="Pester"; ModuleVersion="5.0"}
param(
$ModuleName = "dbatools",
$PSDefaultParameterValues = ($TestConfig = Get-TestConfig).Defaults
)
Describe "Clear-DbaPlanCache" -Tag "UnitTests" {
Context "Parameter validation" {
BeforeAll {
$command = Get-Command Clear-DbaPlanCache
$expected = $TestConfig.CommonParameters
$expected += @(
"SqlInstance",
"SqlCredential",
"Threshold",
"InputObject",
"EnableException",
"Confirm",
"WhatIf"
)
}
It "Has parameter: <_>" -ForEach $expected {
$command | Should -HaveParameter $PSItem
}
It "Should have exactly the number of expected parameters ($($expected.Count))" {
$hasparms = $command.Parameters.Values.Name
Compare-Object -ReferenceObject $expected -DifferenceObject $hasparms | Should -BeNullOrEmpty
}
}
}
Describe "Clear-DbaPlanCache" -Tag "IntegrationTests" {
Context "When not clearing plan cache" {
BeforeAll {
# Make plan cache way higher than likely for a test rig
$threshold = 10240
}
It "Returns correct datatypes" {
$results = Clear-DbaPlanCache -SqlInstance $TestConfig.instance1 -Threshold $threshold
$results.Size | Should -BeOfType [dbasize]
$results.Status | Should -Match 'below'
}
It "Supports piping" {
$results = Get-DbaPlanCache -SqlInstance $TestConfig.instance1 | Clear-DbaPlanCache -Threshold $threshold
$results.Size | Should -BeOfType [dbasize]
$results.Status | Should -Match 'below'
}
}
}