Skip to content

Add wrapper parameter-parity test and backup round-trip test coverage #3

Description

@ekalb81

Problem

Test and validation gaps that allow silent drift:

  1. Wrapper parity. Windows-PATH-Repair.ps1 duplicates the canonical script's parameter list and forwards via @PSBoundParameters. If Windows-Path-Repair-Full.ps1 gains a parameter, the wrapper silently won't accept or forward it (it already intentionally omits -NoExecute). No test asserts the relationship.
  2. Backup functions. Save-PathBackup/Read-PathBackup round-trip is untested, as are Read-PathBackup's rejection paths (missing file, invalid JSON, wrong SchemaVersion/missing properties) and Get-VerifiedDirectoryCandidates. The double-failure path in Invoke-PathUpdate (write fails AND rollback fails → manual-restore message) is also uncovered.
  3. Restore validation is too weak. Read-PathBackup (~line 245) validates property presence but not that MachinePath/UserPath are scalar strings. A hand-edited backup whose value is an array or object gets [string]-cast at ~lines 431–432 into garbage like System.Object[], which Test-PathValueSafety will not catch (it only checks length/empty). Malformed values should be rejected at read time.

Proposed fix

  • Read-PathBackup: reject backups whose MachinePath/UserPath are not strings (null is acceptable only if explicitly allowed), with a clear error naming the offending property.
  • Add Pester tests:
    • Wrapper's parameter set equals the canonical script's minus an explicit allowlist (NoExecute).
    • Round-trip Save-PathBackupRead-PathBackup under $TestDrive (redirect the backup dir or extract a -BackupDirectory parameter to make it testable).
    • Rejection cases for Read-PathBackup: missing file, invalid JSON, wrong schema version, missing properties, non-string values (array/object/number).
    • Rollback-also-fails case for Invoke-PathUpdate using the injectable scriptblock seams.

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