Skip to content

Commit 8c384d7

Browse files
committed
Build formatting changes. Pester test additions/edits. ReadMe Update.
1 parent 3bd3bbd commit 8c384d7

File tree

3 files changed

+159
-77
lines changed

3 files changed

+159
-77
lines changed

Build/psake.ps1

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ Properties {
1313
$lines = '----------------------------------------------------------------------'
1414

1515
$Verbose = @{}
16-
if($ENV:BHCommitMessage -match "!verbose")
17-
{
16+
if ($ENV:BHCommitMessage -match "!verbose") {
1817
$Verbose = @{Verbose = $True}
1918
}
2019
}
@@ -30,23 +29,20 @@ Task Init {
3029
"`n"
3130
}
3231

33-
3432
Task Analyze -Depends Init {
3533
$saResults = Invoke-ScriptAnalyzer -Path $ENV:BHModulePath -Severity @('Error', 'Warning') -Recurse -Verbose:$false
3634
if ($saResults) {
37-
$saResults | Format-Table
38-
#Write-Error -Message 'One or more Script Analyzer errors/warnings where found. Build cannot continue!'
35+
$saResults | Format-Table
36+
# Write-Error -Message 'One or more Script Analyzer errors/warnings where found. Build cannot continue!'
3937
}
4038
}
4139

42-
4340
Task UnitTests -Depends Init {
4441
$lines
4542
'Running quick unit tests to fail early if there is an error'
46-
$TestResults = Invoke-Pester -Path $ProjectRoot\Tests\*unit* -PassThru -Tag Build
47-
48-
if($TestResults.FailedCount -gt 0)
49-
{
43+
$TestResults = Invoke-Pester -Path $ProjectRoot\Tests\*unit* -PassThru -Tag Build
44+
45+
if($TestResults.FailedCount -gt 0) {
5046
Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
5147
}
5248
"`n"
@@ -63,13 +59,12 @@ Task Test -Depends UnitTests {
6359
$CodeCoverage.AddRange($CodeFiles.FullName)
6460
$Script:TestResults = Invoke-Pester -Path $ProjectRoot\Tests -CodeCoverage $CodeCoverage -PassThru -OutputFormat NUnitXml -OutputFile $TestFilePath
6561

66-
# In Appveyor? Upload our tests! #Abstract this into a function?
67-
If($ENV:BHBuildSystem -eq 'AppVeyor')
68-
{
69-
[xml]$content = Get-Content $TestFilePath
70-
$content.'test-results'.'test-suite'.type = "Powershell"
71-
$content.Save($TestFilePath)
62+
[xml]$content = Get-Content $TestFilePath
63+
$content.'test-results'.'test-suite'.type = "Powershell"
64+
$content.Save($TestFilePath)
7265

66+
# In Appveyor? Upload our tests! #Abstract this into a function?
67+
If($ENV:BHBuildSystem -eq 'AppVeyor') {
7368
"Uploading $ProjectRoot\$TestFile to AppVeyor"
7469
"JobID: $env:APPVEYOR_JOB_ID"
7570
(New-Object 'System.Net.WebClient').UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $TestFilePath))
@@ -79,8 +74,7 @@ Task Test -Depends UnitTests {
7974

8075
# Failed tests?
8176
# Need to tell psake or it will proceed to the deployment. Danger!
82-
if($TestResults.FailedCount -gt 0)
83-
{
77+
if($TestResults.FailedCount -gt 0) {
8478
Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed"
8579
}
8680
"`n"
@@ -89,9 +83,9 @@ Task Test -Depends UnitTests {
8983
Task Build -Depends Test {
9084
$lines
9185

92-
$functions = Get-ChildItem "$ENV:BHModulePath\Public\*.ps1" |
93-
Where-Object{ $_.name -notmatch 'Tests'} |
94-
Select-Object -ExpandProperty basename
86+
$functions = Get-ChildItem "$ENV:BHModulePath\Public\*.ps1" |
87+
Where-Object {$_.name -notmatch 'Tests'} |
88+
Select-Object -ExpandProperty basename
9589

9690
# Load the module, read the exported functions, update the psd1 FunctionsToExport
9791
Set-ModuleFunctions -Name $env:BHPSModuleManifest -FunctionsToExport $functions
@@ -105,11 +99,11 @@ Task Build -Depends Test {
10599
}
106100
$Script:version = [version]::New($version.Major,$version.Minor,$version.Build)
107101
Write-Host "Using version: $version"
108-
102+
109103
Update-Metadata -Path $env:BHPSModuleManifest -PropertyName ModuleVersion -Value $version
110104

111105
# Update Code Coverage
112-
Function Update-CodeCoveragePercent{
106+
Function Update-CodeCoveragePercent {
113107
param(
114108
[int]$CodeCoverage=0,
115109
[string]$TextFilePath="$Env:BHProjectPath\Readme.md"
@@ -138,16 +132,15 @@ Task Build -Depends Test {
138132
Task MakePackage -Depends Build,Test {
139133
$lines
140134

141-
function ZipFiles
142-
{
135+
function ZipFiles {
143136
param( $zipfilename, $sourcedir )
144-
Add-Type -Assembly System.IO.Compression.FileSystem
137+
Add-Type -Assembly System.IO.Compression.FileSystem
145138
$compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
146139
[System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir,
147-
$zipfilename, $compressionLevel, $true)
140+
$zipfilename, $compressionLevel, $true)
148141
}
149142

150-
function New-MakePackage{
143+
function New-MakePackage {
151144
param(
152145
[string]$PackageName,
153146
[string]$PackagePath,
@@ -171,24 +164,21 @@ Task Deploy -Depends Build,MakePackage {
171164
$lines
172165

173166
# Gate deployment
174-
if(
167+
if (
175168
$ENV:BHBuildSystem -ne 'Unknown' -and
176169
$ENV:BHBranchName -eq "master" -and
177170
$ENV:BHCommitMessage -match '!deploy'
178-
)
179-
{
171+
) {
180172
$Params = @{
181173
Path = $ProjectRoot
182174
Force = $true
183175
}
184176

185177
Invoke-PSDeploy @Verbose @Params
186-
}
187-
else
188-
{
178+
} else {
189179
"Skipping deployment: To deploy, ensure that...`n" +
190180
"`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" +
191181
"`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" +
192182
"`t* Your commit message includes !deploy (Current: $ENV:BHCommitMessage)"
193183
}
194-
}
184+
}

Readme.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ServiceNow
22

3-
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-74%25-orange.svg)
3+
[![GitHub release](https://img.shields.io/github/release/Sam-Martin/servicenow-powershell.svg)](https://github.com/Sam-Martin/servicenow-powershell/releases/latest) [![GitHub license](https://img.shields.io/github/license/Sam-Martin/servicenow-powershell.svg)](LICENSE) ![Test Coverage](https://img.shields.io/badge/coverage-78%25-yellow.svg)
44

55
This PowerShell module provides a series of cmdlets for interacting with the [ServiceNow REST API](http://wiki.servicenow.com/index.php?title=REST_API), performed by wrapping `Invoke-RestMethod` for the API calls.
66

@@ -77,9 +77,11 @@ The `Connection` parameter accepts a hashtable object that requires a username,
7777
## Cmdlets
7878

7979
* Get-ServiceNowChangeRequest
80-
* Get-ServiceNowConfigurationItem
80+
* Get-ServiceNowConfigurationIte
8181
* Get-ServiceNowIncident
82+
* Get-ServiceNowRequest
8283
* Get-ServiceNowTable
84+
* Get-ServiceNowTableEntry
8385
* Get-ServiceNowUser
8486
* Get-ServiceNowUserGroup
8587
* New-ServiceNowIncident
@@ -91,6 +93,7 @@ The `Connection` parameter accepts a hashtable object that requires a username,
9193
* Test-ServiceNowAuthIsSet
9294
* Update-ServiceNowChangeRequest
9395
* Update-ServiceNowIncident
96+
* Update-ServiceNowNumber
9497
* Update-ServiceNowTableEntry
9598

9699
## Tests

0 commit comments

Comments
 (0)