Skip to content

Commit 9bb7032

Browse files
authored
Merge pull request #78 from homotechsual/develop
Add unit and routing tests for Halo API commands and improve coverage
2 parents 08069b0 + a3093ee commit 9bb7032

17 files changed

Lines changed: 4694 additions & 658 deletions

.codecov.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# This file is generated by DevOps/Quality/Generate-CodecovComponents.ps1
2+
# Source of truth: DevOps/Quality/codecov-components-map.json
3+
component_management:
4+
individual_components:
5+
- component_id: tickets
6+
name: Tickets
7+
paths:
8+
- Public/**/*Ticket*.ps1
9+
- Private/**/*Ticket*.ps1
10+
- Classes/**/*Ticket*.psm1
11+
- component_id: actions
12+
name: Actions
13+
paths:
14+
- Public/**/*Action*.ps1
15+
- Private/**/*Action*.ps1
16+
- Data/Templates/Action.json
17+
- component_id: assets
18+
name: Assets
19+
paths:
20+
- Public/**/*Asset*.ps1
21+
- Private/**/*Asset*.ps1
22+
- Data/Templates/Asset.json
23+
- component_id: clients
24+
name: Clients
25+
paths:
26+
- Public/**/*Client*.ps1
27+
- Public/**/*Site*.ps1
28+
- Public/**/*Supplier*.ps1
29+
- Data/Templates/Client.json
30+
- Data/Templates/Site.json
31+
- Data/Templates/Supplier.json
32+
- component_id: billing
33+
name: Billing
34+
paths:
35+
- Public/**/*Invoice*.ps1
36+
- Public/**/*Quote*.ps1
37+
- Public/**/*BillingTemplate*.ps1
38+
- Public/**/*SalesOrder*.ps1
39+
- Data/Templates/Invoice.json
40+
- Data/Templates/Quote.json
41+
- component_id: knowledge
42+
name: Knowledge
43+
paths:
44+
- Public/**/*KB*.ps1
45+
- Public/**/*FAQ*.ps1
46+
- Public/**/*Article*.ps1
47+
- Data/Templates/KBArticle.json
48+

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ jobs:
8888
$ErrorActionPreference = 'Stop'
8989
& "$env:GITHUB_WORKSPACE\Bootstrap.ps1"
9090
91+
- name: Validate Codecov component config
92+
shell: pwsh
93+
run: |
94+
$ErrorActionPreference = 'Stop'
95+
pwsh -NoProfile -File "$env:GITHUB_WORKSPACE\DevOps\Quality\Generate-CodecovComponents.ps1" -Validate
96+
9197
- name: Run metadata tests
9298
shell: pwsh
9399
run: |
@@ -141,7 +147,7 @@ jobs:
141147
shell: pwsh
142148
run: |
143149
$ErrorActionPreference = 'Stop'
144-
pwsh -NoProfile -File "$env:GITHUB_WORKSPACE\DevOps\Quality\test.ps1" -Suite Unit -Verbosity Detailed -CodeCoverage -MinimumCoveragePercent 20
150+
pwsh -NoProfile -File "$env:GITHUB_WORKSPACE\DevOps\Quality\test.ps1" -Suite Unit -Verbosity Detailed -CodeCoverage -MinimumCoveragePercent 70
145151
146152
- name: Upload unit test results
147153
if: always()

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ Sign-Module.ps1
33
.artifacts/
44
TestResults.xml
55
resource_mappings*.csv
6+
test_output.txt
7+
cmdlets.txt
8+
tests_content.txt

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
If you contributed one of these and there's no credit in the line PR to add it or let me know!
44

5+
## 2026-04-29 - Version 1.23.1
6+
7+
* Fix `Get-HaloTicket` pagination behavior so explicitly providing `-PageNo` and/or `-PageSize` no longer auto-fetches all pages.
8+
59
## 2026-04-26 - Version 1.23.0
610

711
* Add new cmdlets and endpoints including Sales Orders, Templates, Distribution Lists, Controls, Asset Groups, and Custom Field removal.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<#
2+
.SYNOPSIS
3+
Generates the repository Codecov components configuration from a JSON map.
4+
.DESCRIPTION
5+
Produces .codecov.yml from DevOps/Quality/codecov-components-map.json.
6+
When -Validate is provided, compares generated content to the checked-in
7+
file and fails if drift is detected.
8+
#>
9+
[CmdletBinding()]
10+
param(
11+
[string]$MapPath,
12+
[string]$OutputPath,
13+
[switch]$Validate
14+
)
15+
16+
$repoRoot = Resolve-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath '..\..')
17+
18+
if (-not $MapPath) {
19+
$MapPath = Join-Path -Path $PSScriptRoot -ChildPath 'codecov-components-map.json'
20+
}
21+
if (-not $OutputPath) {
22+
$OutputPath = Join-Path -Path $repoRoot -ChildPath '.codecov.yml'
23+
}
24+
25+
if (-not (Test-Path -Path $MapPath)) {
26+
throw ('Codecov component map file not found: {0}' -f $MapPath)
27+
}
28+
29+
$map = Get-Content -Path $MapPath -Raw | ConvertFrom-Json
30+
if ($null -eq $map.components -or $map.components.Count -eq 0) {
31+
throw 'Codecov component map does not contain any components.'
32+
}
33+
34+
$generatedLines = @(
35+
'# This file is generated by DevOps/Quality/Generate-CodecovComponents.ps1',
36+
'# Source of truth: DevOps/Quality/codecov-components-map.json',
37+
'component_management:',
38+
' individual_components:'
39+
)
40+
41+
foreach ($component in $map.components) {
42+
if ([string]::IsNullOrWhiteSpace($component.id)) {
43+
throw 'A component id is missing in the map file.'
44+
}
45+
if ([string]::IsNullOrWhiteSpace($component.name)) {
46+
throw ('Component ''{0}'' is missing a name in the map file.' -f $component.id)
47+
}
48+
if ($null -eq $component.paths -or $component.paths.Count -eq 0) {
49+
throw ('Component ''{0}'' does not define any paths in the map file.' -f $component.id)
50+
}
51+
52+
$generatedLines += (' - component_id: {0}' -f $component.id)
53+
$generatedLines += (' name: {0}' -f $component.name)
54+
$generatedLines += ' paths:'
55+
56+
foreach ($pathPattern in $component.paths) {
57+
if ([string]::IsNullOrWhiteSpace($pathPattern)) {
58+
continue
59+
}
60+
$generatedLines += (' - {0}' -f $pathPattern)
61+
}
62+
}
63+
64+
$generatedContent = ($generatedLines -join "`n") + "`n"
65+
66+
function Normalize-TextForComparison {
67+
param(
68+
[string]$Text
69+
)
70+
71+
if ($null -eq $Text) {
72+
return ''
73+
}
74+
75+
$normalized = $Text -replace "`r`n", "`n"
76+
if ($normalized.Length -gt 0 -and $normalized[0] -eq [char]0xFEFF) {
77+
$normalized = $normalized.Substring(1)
78+
}
79+
80+
return $normalized.TrimEnd("`n")
81+
}
82+
83+
if ($Validate) {
84+
if (-not (Test-Path -Path $OutputPath)) {
85+
throw ('Codecov config file is missing: {0}' -f $OutputPath)
86+
}
87+
88+
$existingContent = Get-Content -Path $OutputPath -Raw
89+
if ((Normalize-TextForComparison -Text $existingContent) -ne (Normalize-TextForComparison -Text $generatedContent)) {
90+
throw 'Codecov component config drift detected. Run: pwsh -File .\DevOps\Quality\Generate-CodecovComponents.ps1'
91+
}
92+
93+
Write-Host 'Codecov component config validation passed.' -ForegroundColor Green
94+
return
95+
}
96+
97+
Set-Content -Path $OutputPath -Value $generatedContent -Encoding utf8
98+
Write-Host ('Generated Codecov component config at: {0}' -f $OutputPath) -ForegroundColor Green
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"components": [
3+
{
4+
"id": "tickets",
5+
"name": "Tickets",
6+
"paths": [
7+
"Public/**/*Ticket*.ps1",
8+
"Private/**/*Ticket*.ps1",
9+
"Classes/**/*Ticket*.psm1"
10+
]
11+
},
12+
{
13+
"id": "actions",
14+
"name": "Actions",
15+
"paths": [
16+
"Public/**/*Action*.ps1",
17+
"Private/**/*Action*.ps1",
18+
"Data/Templates/Action.json"
19+
]
20+
},
21+
{
22+
"id": "assets",
23+
"name": "Assets",
24+
"paths": [
25+
"Public/**/*Asset*.ps1",
26+
"Private/**/*Asset*.ps1",
27+
"Data/Templates/Asset.json"
28+
]
29+
},
30+
{
31+
"id": "clients",
32+
"name": "Clients",
33+
"paths": [
34+
"Public/**/*Client*.ps1",
35+
"Public/**/*Site*.ps1",
36+
"Public/**/*Supplier*.ps1",
37+
"Data/Templates/Client.json",
38+
"Data/Templates/Site.json",
39+
"Data/Templates/Supplier.json"
40+
]
41+
},
42+
{
43+
"id": "billing",
44+
"name": "Billing",
45+
"paths": [
46+
"Public/**/*Invoice*.ps1",
47+
"Public/**/*Quote*.ps1",
48+
"Public/**/*BillingTemplate*.ps1",
49+
"Public/**/*SalesOrder*.ps1",
50+
"Data/Templates/Invoice.json",
51+
"Data/Templates/Quote.json"
52+
]
53+
},
54+
{
55+
"id": "knowledge",
56+
"name": "Knowledge",
57+
"paths": [
58+
"Public/**/*KB*.ps1",
59+
"Public/**/*FAQ*.ps1",
60+
"Public/**/*Article*.ps1",
61+
"Data/Templates/KBArticle.json"
62+
]
63+
}
64+
]
65+
}

Docs/HaloAPI/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sidebar_position: 0
1010
[![GitHub contributors](https://img.shields.io/github/contributors/homotechsual/haloapi?style=for-the-badge&logo=github)](https://github.com/homotechsual/haloapi/)
1111
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/homotechsual/HaloAPI/release.yml?style=for-the-badge&label=Release)](https://github.com/homotechsual/HaloAPI/actions/workflows/release.yml)
1212
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/homotechsual/HaloAPI/ci.yml?style=for-the-badge&label=CI)](https://github.com/homotechsual/HaloAPI/actions/workflows/ci.yml)
13-
![Codecov (with branch)](https://img.shields.io/codecov/c/github/homotechsual/HaloAPI/develop?style=for-the-badge)
13+
[![Codecov (with branch)](https://img.shields.io/codecov/c/github/homotechsual/HaloAPI/develop?style=for-the-badge)](https://codecov.io/gh/homotechsual/HaloAPI)
1414
[![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/HaloAPI?style=for-the-badge)](https://www.powershellgallery.com/packages/HaloAPI/)
1515
[![License](https://img.shields.io/github/license/homotechsual/HaloAPI?style=for-the-badge)](https://mit.license.homotechsual.dev)
1616
[![GitHub Sponsors](https://img.shields.io/github/sponsors/homotechsual?style=for-the-badge)](https://github.com/sponsors/homotechsual/)
@@ -26,7 +26,7 @@ This module provides a PowerShell interface to the Halo API. It's designed to fo
2626

2727
Code coverage is generated in CI for the `Meta` and `Unit` suites.
2828

29-
CI enforces a minimum 20% coverage threshold for the `Unit` suite.
29+
CI enforces a minimum 70% coverage threshold for the `Unit` suite.
3030

3131
Coverage artifacts are uploaded for each run as:
3232

HaloAPI.code-workspace

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
"folders": [
33
{
44
"path": ".",
5-
},
6-
{
7-
"path": "../NinjaOne",
8-
},
5+
}
96
],
107
"settings": {
118
"editor.tabSize": 4,
@@ -227,8 +224,21 @@
227224
"matchCommandLine": true,
228225
},
229226
"PSObject": true,
227+
"/^pwsh -File \\.\\\\DevOps\\\\Quality\\\\test\\.ps1 -Suite Unit -Verbosity Detailed -CodeCoverage -MinimumCoveragePercent 20$/": {
228+
"approve": true,
229+
"matchCommandLine": true,
230+
},
230231
},
231-
"cSpell.words": ["HAPI"],
232+
"cSpell.words": [
233+
"Analyzed",
234+
"dorny",
235+
"HALOTESTINGCLIENTID",
236+
"HALOTESTINGTENANT",
237+
"HALOTESTINGURL",
238+
"HAPI",
239+
"pscustomobject",
240+
"vars",
241+
],
232242
"codeQL.githubDatabase.download": "never",
233243
},
234244
}

HaloAPI.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = '.\HaloAPI.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.23.0'
15+
ModuleVersion = '1.23.1'
1616

1717
# Supported PSEditions
1818
CompatiblePSEditions = @('Core')

0 commit comments

Comments
 (0)