Skip to content

Commit 3009271

Browse files
committed
Task 001 complete
1 parent 5bcb518 commit 3009271

2 files changed

Lines changed: 80 additions & 2 deletions

File tree

specs/feat/paramsets-install-speckit/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
Follow these executable tasks in order. Tasks marked with **[P]** can run in parallel because they modify different files and have no dependency overlap. Each task lists required files, dependencies, and success criteria so an LLM or human can execute it without extra context.
99

10-
## Phase 3.1 – Setup
11-
- [ ] **T001** Prepare host simulation helpers for tests
10+
-## Phase 3.1 – Setup
11+
- [X] **T001** Prepare host simulation helpers for tests
1212
- Files: `tests/Support/HostMocks.ps1`
1313
- Work: Add a reusable helper module exposing `New-TestHostInteractive`, `New-TestHostNonInteractive`, and prompt transcript utilities so unit/integration tests can simulate TTY/non-TTY behavior without altering global host state.
1414
- Depends on: —

tests/Support/HostMocks.ps1

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<#
2+
Helper test host objects and prompt transcript utilities for Pester tests.
3+
4+
Provides:
5+
- New-TestHostInteractive
6+
- New-TestHostNonInteractive
7+
- Start-TestPromptTranscript
8+
- Add-TestPromptEntry
9+
- Get-TestPromptTranscript
10+
- Clear-TestPromptTranscript
11+
12+
#>
13+
14+
function New-TestHostInteractive {
15+
<# Creates a PSCustomObject that mimics $Host with UI.RawUI that indicates a TTY is available. #>
16+
$rawUI = [PSCustomObject]@{
17+
KeyAvailable = $true
18+
CursorSize = 1
19+
BackgroundColor = 'Black'
20+
ForegroundColor = 'White'
21+
WindowSize = [PSCustomObject]@{ Width = 120; Height = 30 }
22+
BufferSize = [PSCustomObject]@{ Width = 120; Height = 300 }
23+
CursorPosition = [PSCustomObject]@{ X = 0; Y = 0 }
24+
}
25+
26+
$ui = [PSCustomObject]@{ RawUI = $rawUI }
27+
$testHostObj = [PSCustomObject]@{ Name = 'TestHost'; UI = $ui }
28+
return $testHostObj
29+
}
30+
31+
function New-TestHostNonInteractive {
32+
<# Creates a PSCustomObject that mimics $Host without TTY support (KeyAvailable = $false). #>
33+
$rawUI = [PSCustomObject]@{
34+
KeyAvailable = $false
35+
CursorSize = 1
36+
BackgroundColor = 'Black'
37+
ForegroundColor = 'White'
38+
WindowSize = [PSCustomObject]@{ Width = 80; Height = 25 }
39+
BufferSize = [PSCustomObject]@{ Width = 80; Height = 200 }
40+
CursorPosition = [PSCustomObject]@{ X = 0; Y = 0 }
41+
}
42+
43+
$ui = [PSCustomObject]@{ RawUI = $rawUI }
44+
$testHostObj = [PSCustomObject]@{ Name = 'TestHost'; UI = $ui }
45+
return $testHostObj
46+
}
47+
48+
# Prompt transcript utilities (simple in-memory capture for tests)
49+
if (-not (Test-Path -LiteralPath variable:TestHostPromptTranscript -ErrorAction SilentlyContinue)) {
50+
Set-Variable -Name TestHostPromptTranscript -Scope Script -Value @()
51+
}
52+
53+
function Start-TestPromptTranscript {
54+
Set-Variable -Name TestHostPromptTranscript -Scope Script -Value @()
55+
}
56+
57+
function Add-TestPromptEntry {
58+
param(
59+
[Parameter(Mandatory=$true)] [string] $Prompt,
60+
[Parameter(Mandatory=$true)] [string] $Response
61+
)
62+
$entry = [PSCustomObject]@{
63+
Time = (Get-Date).ToString('o')
64+
Prompt = $Prompt
65+
Response = $Response
66+
}
67+
$script:TestHostPromptTranscript += $entry
68+
}
69+
70+
function Get-TestPromptTranscript {
71+
return ,$script:TestHostPromptTranscript
72+
}
73+
74+
function Clear-TestPromptTranscript {
75+
Set-Variable -Name TestHostPromptTranscript -Scope Script -Value @()
76+
}
77+
78+
# Intentionally do not call Export-ModuleMember here so the file can be dot-sourced from tests.

0 commit comments

Comments
 (0)