-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSla.Tests.ps1
56 lines (47 loc) · 1.79 KB
/
Sla.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
54
55
56
<#
.SYNOPSIS
Run tests around SLAs
.DESCRIPTION
This file is the companion to the Sla.Tests.ps1 file in the unit folder.
This file tests if the query runs correctly.
It does not test the integrity of the query.
See Tests/unit/Sla.Tests.ps1 for testing the integrity of the query.
#>
BeforeAll {
. "$PSScriptRoot\..\E2eTestInit.ps1"
}
Describe -Name 'SLA Tests' -Fixture {
It -Name 'SLA Domains' -Test {
# ----------------------------------------------------------
#
# 1. Retrieve the list of SLAs
#
# (list of 1 but still a list, not a single object)
# ----------------------------------------------------------
$q1 = New-RscQuery -GqlQuery slaDomains -Var @{first = 1 }
$r1 = $q1 | Invoke-Rsc
$totalSlaCount = $r1.count
$retrievedSlaCount = $r1.nodes.count
$totalSlaCount | Should -BeGreaterOrEqual $retreivedSlaCount
if ($retrievedSlaCount -ne 1) {
Set-ItResult -Skipped -Because "This test needs at least 1 SLA to run"
return
}
# The returned SLA object should be a SlaDomain-implementing object
$implementingTypes = Get-RscHelp -Interface SlaDomain -ImplementingTypes
$r1.Nodes | ForEach-Object {
$implementingTypes | Should -Contain $_.GetType().Name
}
# ----------------------------------------------------------
#
# 2. Retrieve a single SLA
#
# ----------------------------------------------------------
$slaId = $r1.nodes[0].id
$q2 = New-RscQuery -GqlQuery slaDomain -Var @{id = $slaId }
$r2 = $q2 | Invoke-Rsc
$r2.Count | Should -Be 1
$implementingTypes | Should -Contain $r2.GetType().Name
$r2.id | Should -Be $slaId
}
}