forked from dataplat/dbatools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-DbaAgentLog.Tests.ps1
39 lines (37 loc) · 1.65 KB
/
Get-DbaAgentLog.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
$CommandName = $MyInvocation.MyCommand.Name.Replace(".Tests.ps1", "")
Write-Host -Object "Running $PSCommandpath" -ForegroundColor Cyan
. "$PSScriptRoot\constants.ps1"
Describe "$CommandName Unit Tests" -Tag 'UnitTests' {
Context "Validate parameters" {
$paramCount = 4
$defaultParamCount = 11
[object[]]$params = (Get-ChildItem function:\Get-DbaAgentLog).Parameters.Keys
$knownParameters = 'SqlInstance', 'SqlCredential', 'LogNumber', 'EnableException'
It "Should contain our specific parameters" {
( (Compare-Object -ReferenceObject $knownParameters -DifferenceObject $params -IncludeEqual | Where-Object SideIndicator -eq "==").Count ) | Should Be $paramCount
}
It "Should only contain $paramCount parameters" {
$params.Count - $defaultParamCount | Should Be $paramCount
}
}
}
Describe "$commandname Integration Tests" -Tags "IntegrationTests" {
Context "Command gets agent log" {
$results = Get-DbaAgentLog -SqlInstance $script:instance2
It "Results are not empty" {
$results | Should Not Be $Null
}
It "Results contain SQLServerAgent version" {
$results.text -like '`[100`] Microsoft SQLServerAgent version*' | Should Be $true
}
It "LogDate is a DateTime type" {
$($results | Select-Object -first 1).LogDate | Should BeOfType DateTime
}
}
Context "Command gets current agent log using LogNumber parameter" {
$results = Get-DbaAgentLog -SqlInstance $script:instance2 -LogNumber 0
It "Results are not empty" {
$results | Should Not Be $Null
}
}
}