Skip to content

Commit 41ca109

Browse files
feat: add valid and invalid test scenarios for PSModule configuration validation
1 parent 696fecf commit 41ca109

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

.github/workflows/Action-Test.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ permissions:
1717
pull-requests: read
1818

1919
jobs:
20-
ActionTestBasic:
21-
name: Action-Test - [Basic]
20+
ActionTestValid:
21+
name: Action-Test - [Valid Configuration]
2222
runs-on: ubuntu-latest
2323
steps:
2424
# Need to check out as part of the test, as its a local action
@@ -31,10 +31,39 @@ jobs:
3131
id: get-settings
3232
uses: ./
3333
with:
34-
SettingsPath: './tests/PSModule.yml'
34+
SettingsPath: './tests/scenarios/valid/PSModule.yml'
3535

3636
- name: Validate Settings Output
3737
shell: pwsh
3838
env:
3939
SETTINGS_JSON: ${{ steps.get-settings.outputs.Settings }}
4040
run: ./tests/Validate-Settings.ps1
41+
42+
ActionTestInvalidMissingTestConfig:
43+
name: Action-Test - [Invalid - Missing Test Config]
44+
runs-on: ubuntu-latest
45+
steps:
46+
# Need to check out as part of the test, as its a local action
47+
- name: Checkout repo
48+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
49+
with:
50+
persist-credentials: false
51+
52+
- name: Action-Test
53+
id: get-settings
54+
uses: ./
55+
with:
56+
SettingsPath: './tests/scenarios/invalid-missing-test-config/PSModule.yml'
57+
58+
- name: Validate Settings Output (Expect Failure)
59+
shell: pwsh
60+
env:
61+
SETTINGS_JSON: ${{ steps.get-settings.outputs.Settings }}
62+
run: |
63+
$ErrorActionPreference = 'Continue'
64+
./tests/Validate-Settings.ps1
65+
if ($LASTEXITCODE -eq 0) {
66+
Write-Error 'Expected validation to fail for invalid configuration, but it succeeded'
67+
exit 1
68+
}
69+
Write-Host '✓ Validation failed as expected for invalid configuration'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Name: PSModuleTest
2+
Test:
3+
SourceCode:
4+
Skip: true
5+
PSModule:
6+
Linux:
7+
Skip: true
8+
Module:
9+
Skip: false
10+
# Missing TestName and TestPath - this should cause validation to fail
11+
CodeCoverage:
12+
PercentTarget: 1
13+
Publish:
14+
AutoCleanup: false
15+
Linter:
16+
env:
17+
VALIDATE_BIOME_FORMAT: false
18+
VALIDATE_BIOME_LINT: false
19+
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
20+
VALIDATE_JSCPD: false
21+
VALIDATE_JSON_PRETTIER: false
22+
VALIDATE_MARKDOWN_PRETTIER: false
23+
VALIDATE_YAML_PRETTIER: false

0 commit comments

Comments
 (0)