Skip to content

Test-suite hygiene: copied prompt boilerplate, real registry writes, three Pester floors #85

Description

@ALERTua

Found by a whole-repository review. Three things about how the suite is built, none of which changes what it proves today.

The queued-answer boilerplate is copied everywhere

Tests that drive an interactive prompt do this:

$script:answers = @('2', '08:15,13:00', 'sat', '9:00')
$script:index = 0
Mock Read-Host { $script:answers[$script:index++] }

It appears near-verbatim in at least eight Describe blocks, with no automatic reset between tests. A test that forgets $script:index = 0 reads whatever the previous test left behind, and does so silently - it will usually still pass, on the wrong input.

One shared helper - set the queue, reset the counter, install the mock - removes both the repetition and the failure mode.

The registry tests write real keys

Get-FixedDriveWritePolicy's tests create keys under HKCU:\Software\DevDriveTests. Cleanup was fixed to remove the whole branch in AfterAll, and it does, but a killed run still leaves residue in the user's hive. Two tests in that very block prove that mocking Test-Path and Get-ItemProperty is enough to cover the paths that matter. Prefer the mocks.

Three different Pester floors

  • the suite declares #Requires Pester 5.0
  • the pre-commit hook accepts any Pester 5 or newer
  • CI pins 6.1.0

So a contributor on Pester 5.x can pass the hook and fail CI on behaviour that differs between the two. Pin the hook's floor to what CI actually runs, or say in AGENTS.md that the gap exists and what it costs.

Scope

dev_drive.Tests.ps1, .githooks/pre-commit, and possibly AGENTS.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions