Repository navigation
test(v3.2.65): New-CloudSchedule.ps1 ユニットテスト追加 — Build-CreatePrompt / New-LoopPreset 23件 #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,180 @@ | ||||||||
| # ============================================================ | ||||||||
| # NewCloudSchedule.Tests.ps1 - New-CloudSchedule.ps1 unit tests | ||||||||
| # Pester 5.x / Issue #226 | ||||||||
| # | ||||||||
| # Strategy: dot-source the script with exit->return patching so the | ||||||||
| # Pester process is not terminated by the -NonInteractive exit 0. | ||||||||
| # A fake claude.cmd stub is added to PATH to satisfy the CLI check. | ||||||||
| # ============================================================ | ||||||||
|
|
||||||||
| BeforeAll { | ||||||||
| $script:RepoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) | ||||||||
| $script:ScriptPath = Join-Path $script:RepoRoot 'scripts\main\New-CloudSchedule.ps1' | ||||||||
|
|
||||||||
| # --- Fake claude stub (satisfies the CLI-detection block) --- | ||||||||
| $script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) 'pester-cloudschedule-tests' | ||||||||
|
||||||||
| $script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) 'pester-cloudschedule-tests' | |
| $uniqueTempDirName = 'pester-cloudschedule-tests-{0}-{1}' -f $PID, ([guid]::NewGuid().ToString('N')) | |
| $script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) $uniqueTempDirName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一時ディレクトリ名が固定で並列実行時に競合します
$script:TempDir が固定値のため、同時実行時に stub/patch ファイルの上書きや削除競合でテストが不安定になります。ユニーク名にしてください。
💡 修正案
- $script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) 'pester-cloudschedule-tests'
+ $script:TempDir = Join-Path ([System.IO.Path]::GetTempPath()) ("pester-cloudschedule-tests-{0}" -f [guid]::NewGuid().ToString('N'))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/unit/NewCloudSchedule.Tests.ps1` around lines 15 - 25, The temp dir
name is fixed via $script:TempDir causing parallel test collisions; change how
$script:TempDir is constructed (and consequently $script:TempScript and the
claude.cmd path) to include a unique suffix (e.g., a GUID, timestamp, or
[System.IO.Path]::GetRandomFileName()) when calling Join-Path so each test run
gets its own directory, then create that directory as before and use the unique
path everywhere cleanup and file writes reference
$script:TempDir/$script:TempScript.
Copilot
AI
Apr 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit→return パッチの正規表現が「行頭が exit の行」しか置換しないため、New-CloudSchedule.ps1 側の if ($NonInteractive) { exit 0 } / ... { exit 0 } のようなインライン exit が残ります。BeforeAll で -NonInteractive を渡して dot-source しているので、このままだとテスト実行プロセス自体が exit で終了します(Pester が落ちる)。インライン exit も確実に無効化できる置換(例: より広いパターン、AST で ExitStatement を差し替え等)にしてください。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
README 内のテスト件数が不整合です
Line 31 は 703 件に更新されていますが、Line 96 / Line 231 / Line 507 / Line 538 などに旧値が残っており、README 単体で真値が判別しづらい状態です。
💡 修正案(同PR内で揃える)
As per coding guidelines
**/*.md: maintain README as external-facing truth with clear organization, extensive use of tables and icons, and include architecture diagrams.🤖 Prompt for AI Agents