Skip to content

Commit 497b224

Browse files
committed
feat(#100): add architecture guardrails tests for NovaModuleTools
- implement tests for self-update execution order - verify public orchestration entrypoints delegate to context and workflow helpers - ensure project.json persistence is limited to expected callers
1 parent 5a49816 commit 497b224

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

tests/ArchitectureGuardrails.Tests.ps1

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,49 @@ Describe 'Architecture guardrails' {
7171

7272
(Compare-Object -ReferenceObject $expected -DifferenceObject $actual) | Should -BeNullOrEmpty -Because (($actual -join ', '), (& $script:formatMatches -MatchList $matches) -join [Environment]::NewLine)
7373
}
74+
75+
It 'self-update execution stays behind the update command adapter' {
76+
$matches = & $script:findMatches -RootPath $script:srcRoot -Pattern '^\s*(?:return\s+)?Update-Module\b'
77+
$actual = & $script:getMatchedPaths -MatchList $matches
78+
$expected = @('src/private/update/InvokeNovaModuleUpdateCommand.ps1')
79+
80+
(Compare-Object -ReferenceObject $expected -DifferenceObject $actual) | Should -BeNullOrEmpty -Because (($actual -join ', '), (& $script:formatMatches -MatchList $matches) -join [Environment]::NewLine)
81+
}
82+
83+
It 'public orchestration entrypoints keep delegating to their context and workflow helpers' {
84+
$testCases = @(
85+
[pscustomobject]@{Path = 'src/public/DeployNovaPackage.ps1'; ContextPattern = '\bGet-NovaPackageUploadWorkflowContext\b'; ActionPattern = '\bInvoke-NovaPackageUploadWorkflow\b'}
86+
[pscustomobject]@{Path = 'src/public/InitializeNovaModule.ps1'; ContextPattern = '\bGet-NovaModuleInitializationWorkflowContext\b'; ActionPattern = '\bInvoke-NovaModuleInitializationWorkflow\b'}
87+
[pscustomobject]@{Path = 'src/public/InstallNovaCli.ps1'; ContextPattern = '\bGet-NovaCliInstallWorkflowContext\b'; ActionPattern = '\bInvoke-NovaCliInstallWorkflow\b'}
88+
[pscustomobject]@{Path = 'src/public/InvokeNovaBuild.ps1'; ContextPattern = '\bGet-NovaBuildWorkflowContext\b'; ActionPattern = '\bInvoke-NovaBuildWorkflow\b'}
89+
[pscustomobject]@{Path = 'src/public/InvokeNovaCli.ps1'; ContextPattern = '\bGet-NovaCliInvocationContext\b'; ActionPattern = '\bInvoke-NovaCliCommandRoute\b'}
90+
[pscustomobject]@{Path = 'src/public/InvokeNovaRelease.ps1'; ContextPattern = '\bGet-NovaPublishWorkflowContext\b'; ActionPattern = '\bInvoke-NovaReleaseWorkflow\b'}
91+
[pscustomobject]@{Path = 'src/public/NewNovaModulePackage.ps1'; ContextPattern = '\bGet-NovaPackageWorkflowContext\b'; ActionPattern = '\bInvoke-NovaPackageWorkflow\b'}
92+
[pscustomobject]@{Path = 'src/public/PublishNovaModule.ps1'; ContextPattern = '\bGet-NovaPublishWorkflowContext\b'; ActionPattern = '\bInvoke-NovaPublishWorkflow\b'}
93+
[pscustomobject]@{Path = 'src/public/SetNovaUpdateNotificationPreference.ps1'; ContextPattern = '\bGet-NovaUpdateNotificationPreferenceChangeContext\b'; ActionPattern = '\bInvoke-NovaUpdateNotificationPreferenceChange\b'}
94+
[pscustomobject]@{Path = 'src/public/TestNovaBuild.ps1'; ContextPattern = '\bGet-NovaTestWorkflowContext\b'; ActionPattern = '\bInvoke-NovaTestWorkflow\b'}
95+
[pscustomobject]@{Path = 'src/public/UpdateNovaModuleTools.ps1'; ContextPattern = '\bGet-NovaModuleSelfUpdateWorkflowContext\b'; ActionPattern = '\bInvoke-NovaModuleSelfUpdateWorkflow\b'}
96+
[pscustomobject]@{Path = 'src/public/UpdateNovaModuleVersion.ps1'; ContextPattern = '\bGet-NovaVersionUpdateWorkflowContext\b'; ActionPattern = '\bInvoke-NovaVersionUpdateWorkflow\b'}
97+
)
98+
99+
foreach ($testCase in $testCases) {
100+
$filePath = Join-Path $script:repoRoot $testCase.Path
101+
$content = Get-Content -LiteralPath $filePath -Raw
102+
103+
$content | Should -Match $testCase.ContextPattern -Because "$( $testCase.Path ) should build or resolve its workflow/context state before orchestration"
104+
$content | Should -Match $testCase.ActionPattern -Because "$( $testCase.Path ) should delegate execution to its workflow or routing helper"
105+
}
106+
}
107+
108+
It 'project.json persistence stays limited to the shared writer and its expected callers' {
109+
$matches = & $script:findMatches -RootPath $script:srcRoot -Pattern '\bWrite-ProjectJsonData\b'
110+
$actual = & $script:getMatchedPaths -MatchList $matches
111+
$expected = @(
112+
'src/private/release/SetNovaModuleVersion.ps1'
113+
'src/private/scaffold/WriteNovaModuleProjectJson.ps1'
114+
'src/private/shared/Write-ProjectJsonData.ps1'
115+
)
116+
117+
(Compare-Object -ReferenceObject $expected -DifferenceObject $actual) | Should -BeNullOrEmpty -Because (($actual -join ', '), (& $script:formatMatches -MatchList $matches) -join [Environment]::NewLine)
118+
}
74119
}

0 commit comments

Comments
 (0)