@@ -5,7 +5,8 @@ $DefaultsFile = Join-Path $projectRoot "Tests\$($ModuleName).Pester.Defaults.jso
55
66# Load defaults from file (merging into $global:ServiceNowPesterTestDefaults)
77if (Test-Path $DefaultsFile ){
8- $defaults = if ($global :ServiceNowPesterTestDefaults ){$global :ServiceNowPesterTestDefaults }else {@ {}};
8+ $defaults = @ {}
9+ # Add properties to the defaults hash
910 (Get-Content $DefaultsFile | Out-String | ConvertFrom-Json ).psobject.properties | ForEach-Object {
1011 $defaults ." $ ( $_.Name ) " = $_.Value
1112 }
@@ -15,16 +16,15 @@ if(Test-Path $DefaultsFile){
1516
1617 $global :ServiceNowPesterTestDefaults = $defaults
1718}else {
18- Write-Error " $DefaultsFile does not exist. Created example file. Please populate with your values"
19-
2019 # Write example file
2120 @ {
2221 ServiceNowURL = ' testingurl.service-now.com'
2322 TestCategory = ' Internal'
2423 TestUserGroup = ' e9e9a2406f4c35001855fa0dba3ee4f3'
2524 TestUser = " 7a4b573a6f3725001855fa0dba3ee485"
2625 } | ConvertTo-Json | Set-Content $DefaultsFile
27- return
26+ Write-Error " $DefaultsFile does not exist. Created example file. Please populate with your values"
27+ Return
2828}
2929
3030# Load the module (unload it first in case we've made changes since loading it previously)
@@ -33,19 +33,19 @@ Import-Module (Join-Path $moduleRoot "$moduleName.psd1") -Force
3333
3434Describe " ServiceNow-Module" {
3535 If (Test-ServiceNowAuthisSet ) {
36- Remove-ServiceNowAuth
36+ Remove-ServiceNowAuth | Should - Be $True
3737 }
3838
3939 It " Test-ServiceNowAuthIsSet not set" {
40- Test-ServiceNowAuthIsSet | Should be $false
40+ Test-ServiceNowAuthIsSet | Should - Be $false
4141 }
4242
4343 It " Set-ServiceNowAuth works" {
44- Set-ServiceNowAuth - url $defaults.ServiceNowURL - Credentials $defaults.Creds | Should be $true
44+ Set-ServiceNowAuth - url $defaults.ServiceNowURL - Credentials $defaults.Creds | Should - Be $true
4545 }
4646
4747 It " Test-ServiceNowAuthIsSet set" {
48- Test-ServiceNowAuthIsSet | Should be $true
48+ Test-ServiceNowAuthIsSet | Should - Be $true
4949 }
5050
5151 It " New-ServiceNowIncident (and by extension New-ServiceNowTableEntry) works" {
@@ -58,22 +58,21 @@ Describe "ServiceNow-Module" {
5858 Comment = " Comment"
5959 Category = $Defaults.TestCategory
6060 SubCategory = $Defaults.TestSubcategory
61- ConfigurationItem = $Defaults.TestConfigurationItem
62-
63- }
61+ ConfigurationItem = $Defaults.TestConfigurationIte
62+ }
6463 $TestTicket = New-ServiceNowIncident @newServiceNowIncidentSplat
6564
66- $TestTicket.short_description | Should be $ShortDescription
65+ $TestTicket.short_description | Should - Be $ShortDescription
6766 }
6867
6968 It " Get-ServiceNowTable works" {
7069 # There should be one or more incidents returned
71- (Get-ServiceNowTable - Table ' incident' - Query ' ORDERBYDESCopened_at' ).Count -gt 0 | Should Match $true
70+ (Get-ServiceNowTable - Table ' incident' - Query ' ORDERBYDESCopened_at' ).Count -gt 0 | Should - Match $true
7271 }
7372
7473 It " Get-ServiceNowIncident works" {
7574 # There should be one or more incidents returned
76- (Get-ServiceNowIncident ).Count -gt 0 | Should Match $true
75+ (Get-ServiceNowIncident ).Count -gt 0 | Should - Match $true
7776 }
7877
7978 It " Update-ServiceNowIncident works" {
@@ -88,44 +87,44 @@ Describe "ServiceNow-Module" {
8887 SubCategory = $Defaults.TestSubcategory
8988 ConfigurationItem = $Defaults.TestConfigurationItem
9089
91- }
90+ }
9291 $TestTicket = New-ServiceNowIncident @newServiceNowIncidentSplat
93-
94- $TestTicket.short_description | Should be $ShortDescription
95-
96- $Values =
92+
93+ $TestTicket.short_description | Should - Be $ShortDescription
94+
95+ $Values =
9796 @ {
9897 ' short_description' = ' Ticket Updated with Pester'
99- ' description' = ' Even Longer Description'
98+ ' description' = ' Even Longer Description'
10099 }
101-
100+
102101 Update-ServiceNowIncident - SysId $TestTicket.sys_id - Values $Values
103102
104103 $TestTicket = Get-ServiceNowIncident - MatchExact @ {sys_id = $TestTicket.sys_id }
105- $TestTicket.short_description | Should be " Ticket Updated with Pester"
106- $TestTicket.description | Should be " Even Longer Description"
104+ $TestTicket.short_description | Should - Be " Ticket Updated with Pester"
105+ $TestTicket.description | Should - Be " Even Longer Description"
107106 }
108107
109- It " Get-ServiceNowUserGroup works" {
108+ It " Get-ServiceNowUserGroup works" {
110109 # There should be one or more user groups returned
111- (Get-ServiceNowUserGroup ).Count -gt 0 | Should Match $true
110+ (Get-ServiceNowUserGroup ).Count -gt 0 | Should - Match $true
112111 }
113112
114113 It " Get-ServiceNowUser works" {
115114 # There should be one or more user groups returned
116- (Get-ServiceNowUser ).Count -gt 0 | Should Match $true
115+ (Get-ServiceNowUser ).Count -gt 0 | Should - Match $true
117116 }
118117
119118 It " Get-ServiceNowConfigurationItem works" {
120119 # There should be one or more configuration items returned
121- (Get-ServiceNowConfigurationItem ).Count -gt 0 | Should Match $true
120+ (Get-ServiceNowConfigurationItem ).Count -gt 0 | Should - Match $true
122121 }
123122
124- It " Get-ServiceNowChangeRequest works" {
125- (Get-ServiceNowChangeRequest ).Count -gt 0 | Should Match $true
123+ It " Get-ServiceNowChangeRequest works" {
124+ (Get-ServiceNowChangeRequest ).Count -gt 0 | Should - Match $true
126125 }
127126
128127 It " Remove-ServiceNowAuth works" {
129128 Remove-ServiceNowAuth | Should be $true
130129 }
131- }
130+ }
0 commit comments