microsoft/hve-core

Public

mirrored fromhttps://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/fix-broken-file-references

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/tests/collections/CollectionHelpers.Tests.ps1

564lines · modecode

1#Requires -Modules Pester
2# Copyright (c) Microsoft Corporation.
3# SPDX-License-Identifier: MIT
4
5BeforeAll {
6 Import-Module $PSScriptRoot/../../collections/Modules/CollectionHelpers.psm1 -Force
7}
8
9Describe 'Get-ArtifactFiles - repo-specific path exclusion' {
10 BeforeAll {
11 $script:repoRoot = Join-Path $TestDrive 'repo'
12 $ghDir = Join-Path $script:repoRoot '.github'
13
14 # Create root-level repo-specific agent (should be excluded)
15 $agentsDir = Join-Path $ghDir 'agents'
16 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
17 Set-Content -Path (Join-Path $agentsDir 'internal.agent.md') -Value '---\ndescription: repo-specific\n---'
18
19 # Create collection-scoped agent in subdirectory (should be included)
20 $hveCoreAgentsDir = Join-Path $agentsDir 'hve-core'
21 New-Item -ItemType Directory -Path $hveCoreAgentsDir -Force | Out-Null
22 Set-Content -Path (Join-Path $hveCoreAgentsDir 'rpi-agent.agent.md') -Value '---\ndescription: distributable\n---'
23
24 # Create root-level repo-specific instruction (should be excluded)
25 $instrDir = Join-Path $ghDir 'instructions'
26 New-Item -ItemType Directory -Path $instrDir -Force | Out-Null
27 Set-Content -Path (Join-Path $instrDir 'workflows.instructions.md') -Value '---\ndescription: repo-specific\n---'
28
29 # Create collection-scoped instruction in subdirectory (should be included)
30 $sharedInstrDir = Join-Path $instrDir 'shared'
31 New-Item -ItemType Directory -Path $sharedInstrDir -Force | Out-Null
32 Set-Content -Path (Join-Path $sharedInstrDir 'hve-core-location.instructions.md') -Value '---\ndescription: shared\n---'
33
34 # Create root-level repo-specific prompt (should be excluded)
35 $promptsDir = Join-Path $ghDir 'prompts'
36 New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null
37 Set-Content -Path (Join-Path $promptsDir 'internal.prompt.md') -Value '---\ndescription: repo-specific prompt\n---'
38
39 # Create collection-scoped prompt in subdirectory (should be included)
40 $hveCorePromptsDir = Join-Path $promptsDir 'hve-core'
41 New-Item -ItemType Directory -Path $hveCorePromptsDir -Force | Out-Null
42 Set-Content -Path (Join-Path $hveCorePromptsDir 'task-plan.prompt.md') -Value '---\ndescription: distributable prompt\n---'
43 }
44
45 It 'Excludes root-level repo-specific instructions' {
46 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
47 $paths = $items | ForEach-Object { $_.path }
48 $paths | Should -Not -Contain '.github/instructions/workflows.instructions.md'
49 }
50
51 It 'Excludes root-level repo-specific agents' {
52 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
53 $paths = $items | ForEach-Object { $_.path }
54 $paths | Should -Not -Contain '.github/agents/internal.agent.md'
55 }
56
57 It 'Excludes root-level repo-specific prompts' {
58 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
59 $paths = $items | ForEach-Object { $_.path }
60 $paths | Should -Not -Contain '.github/prompts/internal.prompt.md'
61 }
62
63 It 'Includes collection-scoped agents in subdirectories' {
64 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
65 $paths = $items | ForEach-Object { $_.path }
66 $paths | Should -Contain '.github/agents/hve-core/rpi-agent.agent.md'
67 }
68
69 It 'Includes collection-scoped instructions in subdirectories' {
70 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
71 $paths = $items | ForEach-Object { $_.path }
72 $paths | Should -Contain '.github/instructions/shared/hve-core-location.instructions.md'
73 }
74
75 It 'Includes collection-scoped prompts in subdirectories' {
76 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
77 $paths = $items | ForEach-Object { $_.path }
78 $paths | Should -Contain '.github/prompts/hve-core/task-plan.prompt.md'
79 }
80}
81
82Describe 'Get-ArtifactFiles - deprecated path exclusion' {
83 BeforeAll {
84 $script:repoRoot = Join-Path $TestDrive 'repo-deprecated'
85 $ghDir = Join-Path $script:repoRoot '.github'
86
87 # Create non-deprecated artifacts
88 $agentsDir = Join-Path $ghDir 'agents/rpi'
89 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
90 Set-Content -Path (Join-Path $agentsDir 'active.agent.md') -Value '---\ndescription: active\n---'
91
92 $promptsDir = Join-Path $ghDir 'prompts/rpi'
93 New-Item -ItemType Directory -Path $promptsDir -Force | Out-Null
94 Set-Content -Path (Join-Path $promptsDir 'active.prompt.md') -Value '---\ndescription: active\n---'
95
96 # Create deprecated artifacts
97 $deprecatedAgentsDir = Join-Path $ghDir 'deprecated/agents'
98 New-Item -ItemType Directory -Path $deprecatedAgentsDir -Force | Out-Null
99 Set-Content -Path (Join-Path $deprecatedAgentsDir 'old.agent.md') -Value '---\ndescription: deprecated\n---'
100
101 $deprecatedPromptsDir = Join-Path $ghDir 'deprecated/prompts'
102 New-Item -ItemType Directory -Path $deprecatedPromptsDir -Force | Out-Null
103 Set-Content -Path (Join-Path $deprecatedPromptsDir 'old.prompt.md') -Value '---\ndescription: deprecated\n---'
104
105 $deprecatedInstrDir = Join-Path $ghDir 'deprecated/instructions'
106 New-Item -ItemType Directory -Path $deprecatedInstrDir -Force | Out-Null
107 Set-Content -Path (Join-Path $deprecatedInstrDir 'old.instructions.md') -Value '---\ndescription: deprecated\n---'
108
109 # Create deprecated skill
110 $deprecatedSkillDir = Join-Path $ghDir 'deprecated/skills/old-skill'
111 New-Item -ItemType Directory -Path $deprecatedSkillDir -Force | Out-Null
112 Set-Content -Path (Join-Path $deprecatedSkillDir 'SKILL.md') -Value '---\nname: old-skill\ndescription: deprecated\n---'
113
114 # Create non-deprecated skill (under .github/skills/)
115 $skillDir = Join-Path $ghDir 'skills/experimental/good-skill'
116 New-Item -ItemType Directory -Path $skillDir -Force | Out-Null
117 Set-Content -Path (Join-Path $skillDir 'SKILL.md') -Value '---\nname: good-skill\ndescription: active\n---'
118 }
119
120 It 'Excludes deprecated agent files' {
121 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
122 $paths = $items | ForEach-Object { $_.path }
123 $paths | Should -Not -Contain '.github/deprecated/agents/old.agent.md'
124 }
125
126 It 'Excludes deprecated prompt files' {
127 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
128 $paths = $items | ForEach-Object { $_.path }
129 $paths | Should -Not -Contain '.github/deprecated/prompts/old.prompt.md'
130 }
131
132 It 'Excludes deprecated instruction files' {
133 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
134 $paths = $items | ForEach-Object { $_.path }
135 $paths | Should -Not -Contain '.github/deprecated/instructions/old.instructions.md'
136 }
137
138 It 'Excludes deprecated skill directories' {
139 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
140 $paths = $items | ForEach-Object { $_.path }
141 $paths | Should -Not -Contain '.github/deprecated/skills/old-skill'
142 }
143
144 It 'Includes non-deprecated artifacts' {
145 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
146 $paths = $items | ForEach-Object { $_.path }
147 $paths | Should -Contain '.github/agents/rpi/active.agent.md'
148 $paths | Should -Contain '.github/prompts/rpi/active.prompt.md'
149 }
150
151 It 'Includes non-deprecated skills' {
152 $items = Get-ArtifactFiles -RepoRoot $script:repoRoot
153 $paths = $items | ForEach-Object { $_.path }
154 $paths | Should -Contain '.github/skills/experimental/good-skill'
155 }
156}
157
158Describe 'Test-DeprecatedPath' {
159 It 'Returns true for path containing /deprecated/ segment' {
160 Test-DeprecatedPath -Path '.github/deprecated/agents/old.agent.md' | Should -BeTrue
161 }
162
163 It 'Returns true for path with backslash deprecated segment' {
164 Test-DeprecatedPath -Path '.github\deprecated\agents\old.agent.md' | Should -BeTrue
165 }
166
167 It 'Returns false for path without deprecated segment' {
168 Test-DeprecatedPath -Path '.github/agents/rpi/active.agent.md' | Should -BeFalse
169 }
170
171 It 'Returns false when deprecated appears in filename only' {
172 Test-DeprecatedPath -Path '.github/agents/deprecated-notes.agent.md' | Should -BeFalse
173 }
174
175 It 'Returns true for mid-path deprecated directory' {
176 Test-DeprecatedPath -Path 'skills/deprecated/old-skill/SKILL.md' | Should -BeTrue
177 }
178}
179
180Describe 'Test-HveCoreRepoSpecificPath' {
181 It 'Returns true for root-level file (no subdirectory)' {
182 Test-HveCoreRepoSpecificPath -RelativePath 'workflows.instructions.md' | Should -BeTrue
183 }
184
185 It 'Returns false for file in a subdirectory' {
186 Test-HveCoreRepoSpecificPath -RelativePath 'hve-core/markdown.instructions.md' | Should -BeFalse
187 }
188
189 It 'Returns false for file in nested subdirectory' {
190 Test-HveCoreRepoSpecificPath -RelativePath 'coding-standards/csharp/style.instructions.md' | Should -BeFalse
191 }
192
193 It 'Returns false for shared subdirectory path' {
194 Test-HveCoreRepoSpecificPath -RelativePath 'shared/hve-core-location.instructions.md' | Should -BeFalse
195 }
196}
197
198Describe 'Test-HveCoreRepoRelativePath' {
199 It 'Returns true for root-level agent' {
200 Test-HveCoreRepoRelativePath -Path '.github/agents/internal.agent.md' | Should -BeTrue
201 }
202
203 It 'Returns true for root-level instruction' {
204 Test-HveCoreRepoRelativePath -Path '.github/instructions/workflows.instructions.md' | Should -BeTrue
205 }
206
207 It 'Returns true for root-level prompt' {
208 Test-HveCoreRepoRelativePath -Path '.github/prompts/internal.prompt.md' | Should -BeTrue
209 }
210
211 It 'Returns false for non-.github path' {
212 Test-HveCoreRepoRelativePath -Path 'scripts/plugins/foo.ps1' | Should -BeFalse
213 }
214
215 It 'Returns false for collection-scoped path in subdirectory' {
216 Test-HveCoreRepoRelativePath -Path '.github/agents/hve-core/rpi-agent.agent.md' | Should -BeFalse
217 }
218
219 It 'Returns false for shared instruction in subdirectory' {
220 Test-HveCoreRepoRelativePath -Path '.github/instructions/shared/hve-core-location.instructions.md' | Should -BeFalse
221 }
222
223 It 'Returns false for path directly under .github (wrong nesting level)' {
224 Test-HveCoreRepoRelativePath -Path '.github/foo.md' | Should -BeFalse
225 }
226}
227
228Describe 'Resolve-CollectionItemMaturity' {
229 It 'Returns stable for null' {
230 $result = Resolve-CollectionItemMaturity -Maturity $null
231 $result | Should -Be 'stable'
232 }
233
234 It 'Returns stable for empty string' {
235 $result = Resolve-CollectionItemMaturity -Maturity ''
236 $result | Should -Be 'stable'
237 }
238
239 It 'Returns stable for whitespace' {
240 $result = Resolve-CollectionItemMaturity -Maturity ' '
241 $result | Should -Be 'stable'
242 }
243
244 It 'Passes through preview' {
245 $result = Resolve-CollectionItemMaturity -Maturity 'preview'
246 $result | Should -Be 'preview'
247 }
248
249 It 'Passes through experimental' {
250 $result = Resolve-CollectionItemMaturity -Maturity 'experimental'
251 $result | Should -Be 'experimental'
252 }
253}
254
255Describe 'Test-ArtifactDeprecated' {
256 It 'Returns true for deprecated' {
257 $result = Test-ArtifactDeprecated -Maturity 'deprecated'
258 $result | Should -BeTrue
259 }
260
261 It 'Returns false for stable' {
262 $result = Test-ArtifactDeprecated -Maturity 'stable'
263 $result | Should -BeFalse
264 }
265
266 It 'Returns false for preview' {
267 $result = Test-ArtifactDeprecated -Maturity 'preview'
268 $result | Should -BeFalse
269 }
270
271 It 'Returns false for experimental' {
272 $result = Test-ArtifactDeprecated -Maturity 'experimental'
273 $result | Should -BeFalse
274 }
275
276 It 'Returns false for null (defaults to stable)' {
277 $result = Test-ArtifactDeprecated -Maturity $null
278 $result | Should -BeFalse
279 }
280}
281
282Describe 'Get-ArtifactFrontmatter - YAML parse failure' {
283 It 'Returns fallback when YAML frontmatter is malformed' {
284 $testFile = Join-Path $TestDrive 'bad-yaml.agent.md'
285 # Invalid YAML: tab characters and broken mapping
286 Set-Content -Path $testFile -Value "---`n`t: [invalid: yaml`n---`nBody"
287 $result = Get-ArtifactFrontmatter -FilePath $testFile -FallbackDescription 'fallback-desc'
288 $result.description | Should -Be 'fallback-desc'
289 }
290}
291
292Describe 'Update-HveCoreAllCollection - deprecated item exclusion' {
293 BeforeAll {
294 $script:repoRoot = Join-Path $TestDrive 'repo-deprecated-exclusion'
295 $ghDir = Join-Path $script:repoRoot '.github'
296
297 # Create two artifacts: one active, one that will be marked deprecated in the manifest
298 $agentsDir = Join-Path $ghDir 'agents/test-collection'
299 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
300 Set-Content -Path (Join-Path $agentsDir 'active.agent.md') -Value "---`ndescription: active agent`n---`nBody"
301 Set-Content -Path (Join-Path $agentsDir 'old.agent.md') -Value "---`ndescription: old agent`n---`nBody"
302
303 $collectionsDir = Join-Path $script:repoRoot 'collections'
304 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
305 }
306
307 It 'Excludes items marked deprecated in existing manifest and reports count' {
308 $yaml = @"
309id: hve-core-all
310name: HVE Core All
311description: All artifacts
312tags: []
313items:
314- path: .github/agents/test-collection/active.agent.md
315 kind: agent
316- path: .github/agents/test-collection/old.agent.md
317 kind: agent
318 maturity: deprecated
319display:
320 ordering: alpha
321"@
322 Set-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
323
324 $result = Update-HveCoreAllCollection -RepoRoot $script:repoRoot
325
326 $result.DeprecatedCount | Should -BeGreaterOrEqual 1
327 $output = Get-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Raw
328 $output | Should -Not -Match 'old\.agent\.md'
329 }
330}
331
332Describe 'Update-HveCoreAllCollection - non-stable maturity key' {
333 BeforeAll {
334 $script:repoRoot = Join-Path $TestDrive 'repo-maturity-key'
335 $ghDir = Join-Path $script:repoRoot '.github'
336
337 $agentsDir = Join-Path $ghDir 'agents/test-collection'
338 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
339 Set-Content -Path (Join-Path $agentsDir 'preview.agent.md') -Value "---`ndescription: preview agent`n---`nBody"
340
341 $collectionsDir = Join-Path $script:repoRoot 'collections'
342 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
343 }
344
345 It 'Includes maturity key in output for non-stable items' {
346 $yaml = @"
347id: hve-core-all
348name: HVE Core All
349description: All artifacts
350tags: []
351items:
352- path: .github/agents/test-collection/preview.agent.md
353 kind: agent
354 maturity: preview
355display:
356 ordering: alpha
357"@
358 Set-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
359
360 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
361
362 $output = Get-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Raw
363 $output | Should -Match 'maturity: preview'
364 }
365
366 It 'Omits maturity key for stable items' {
367 $yaml = @"
368id: hve-core-all
369name: HVE Core All
370description: All artifacts
371tags: []
372items:
373- path: .github/agents/test-collection/preview.agent.md
374 kind: agent
375display:
376 ordering: alpha
377"@
378 Set-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
379
380 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
381
382 $output = Get-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Raw
383 $output | Should -Not -Match 'maturity:'
384 }
385}
386
387Describe 'Update-HveCoreAllCollection - new item detection' {
388 BeforeAll {
389 $script:repoRoot = Join-Path $TestDrive 'repo-new-item'
390 $ghDir = Join-Path $script:repoRoot '.github'
391
392 $agentsDir = Join-Path $ghDir 'agents/test-collection'
393 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
394 Set-Content -Path (Join-Path $agentsDir 'existing.agent.md') -Value "---`ndescription: existing agent`n---`nBody"
395 Set-Content -Path (Join-Path $agentsDir 'new.agent.md') -Value "---`ndescription: new agent`n---`nBody"
396
397 $collectionsDir = Join-Path $script:repoRoot 'collections'
398 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
399 }
400
401 It 'Reports added items when new artifacts are discovered' {
402 # Manifest only has the existing agent, discovery will find both
403 $yaml = @"
404id: hve-core-all
405name: HVE Core All
406description: All artifacts
407tags: []
408items:
409- path: .github/agents/test-collection/existing.agent.md
410 kind: agent
411display:
412 ordering: alpha
413"@
414 Set-Content -Path (Join-Path $script:repoRoot 'collections/hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
415
416 $result = Update-HveCoreAllCollection -RepoRoot $script:repoRoot
417
418 $result.AddedCount | Should -BeGreaterOrEqual 1
419 }
420
421 It 'Reports zero added when manifest already contains all artifacts' {
422 # Run update first to sync, then run again
423 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
424 $result = Update-HveCoreAllCollection -RepoRoot $script:repoRoot
425
426 $result.AddedCount | Should -Be 0
427 }
428}
429
430Describe 'Update-HveCoreAllCollection - display key ordering' {
431 BeforeAll {
432 $script:repoRoot = Join-Path $TestDrive 'repo-display-order'
433 $ghDir = Join-Path $script:repoRoot '.github'
434
435 # Create a minimal artifact so discovery finds at least one item
436 $agentsDir = Join-Path $ghDir 'agents/test-collection'
437 New-Item -ItemType Directory -Path $agentsDir -Force | Out-Null
438 Set-Content -Path (Join-Path $agentsDir 'sample.agent.md') -Value "---`ndescription: sample agent`n---`nBody"
439 }
440
441 It 'Preserves featured-then-ordering key order when both keys exist' {
442 $collectionsDir = Join-Path $script:repoRoot 'collections'
443 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
444
445 # Write manifest with ordering BEFORE featured (reversed)
446 $yaml = @"
447id: hve-core-all
448name: HVE Core All
449description: All artifacts
450tags: []
451items:
452- path: .github/agents/test-collection/sample.agent.md
453 kind: agent
454display:
455 ordering: alpha
456 featured:
457 - sample.agent.md
458"@
459 Set-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
460
461 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
462
463 $output = Get-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Raw
464 # featured must appear before ordering in the output
465 $featuredIndex = $output.IndexOf('featured:')
466 $orderingIndex = $output.IndexOf('ordering:')
467 $featuredIndex | Should -BeLessThan $orderingIndex -Because 'featured key should precede ordering key in display section'
468 }
469
470 It 'Handles display with only ordering key' {
471 $collectionsDir = Join-Path $script:repoRoot 'collections'
472 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
473
474 $yaml = @"
475id: hve-core-all
476name: HVE Core All
477description: All artifacts
478tags: []
479items:
480- path: .github/agents/test-collection/sample.agent.md
481 kind: agent
482display:
483 ordering: alpha
484"@
485 Set-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
486
487 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
488
489 $output = Get-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Raw
490 $output | Should -Match 'ordering: alpha'
491 $output | Should -Not -Match 'featured:'
492 }
493
494 It 'Handles display with only featured key' {
495 $collectionsDir = Join-Path $script:repoRoot 'collections'
496 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
497
498 $yaml = @"
499id: hve-core-all
500name: HVE Core All
501description: All artifacts
502tags: []
503items:
504- path: .github/agents/test-collection/sample.agent.md
505 kind: agent
506display:
507 featured:
508 - sample.agent.md
509"@
510 Set-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
511
512 Update-HveCoreAllCollection -RepoRoot $script:repoRoot | Out-Null
513
514 $output = Get-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Raw
515 $output | Should -Match 'featured:'
516 $output | Should -Not -Match 'ordering:'
517 }
518
519 It 'Returns expected result hashtable' {
520 $collectionsDir = Join-Path $script:repoRoot 'collections'
521 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
522
523 $yaml = @"
524id: hve-core-all
525name: HVE Core All
526description: All artifacts
527tags: []
528items:
529- path: .github/agents/test-collection/sample.agent.md
530 kind: agent
531display:
532 ordering: alpha
533"@
534 Set-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
535
536 $result = Update-HveCoreAllCollection -RepoRoot $script:repoRoot
537
538 $result.ItemCount | Should -BeGreaterOrEqual 1
539 $result.Keys | Should -Contain 'AddedCount'
540 $result.Keys | Should -Contain 'RemovedCount'
541 $result.Keys | Should -Contain 'DeprecatedCount'
542 }
543
544 It 'Does not write to disk in DryRun mode' {
545 $collectionsDir = Join-Path $script:repoRoot 'collections'
546 New-Item -ItemType Directory -Path $collectionsDir -Force | Out-Null
547
548 $yaml = @"
549id: hve-core-all
550name: HVE Core All
551description: All artifacts
552tags: []
553items: []
554display:
555 ordering: alpha
556"@
557 Set-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Value $yaml -Encoding utf8 -NoNewline
558
559 Update-HveCoreAllCollection -RepoRoot $script:repoRoot -DryRun | Out-Null
560
561 $output = Get-Content -Path (Join-Path $collectionsDir 'hve-core-all.collection.yml') -Raw
562 $output | Should -Match 'items: \[\]' -Because 'DryRun should not modify the file'
563 }
564}
565