Skip to content

Local Testing

Run local checks from the repository root:

Terminal window
.\scripts\Test-Local.ps1 -ConfigFile .\config.local.yaml

The script:

  • Parses tracked PowerShell script and module files.
  • Validates AzureSqlVmToolkit.psd1.
  • Verifies VERSION matches the module manifest.
  • Parses schemas/config.schema.json.
  • Runs vm_creation_with_bastion.ps1 -Plan.
  • Runs Pester 5 tests when installed.
  • Runs PSScriptAnalyzer when installed.

Install optional local test tooling:

Terminal window
Install-Module -Name powershell-yaml -RequiredVersion 0.4.12 -Scope CurrentUser -Force
Install-Module -Name Pester -RequiredVersion 5.7.1 -Scope CurrentUser -Force -SkipPublisherCheck
Install-Module -Name PSScriptAnalyzer -RequiredVersion 1.25.0 -Scope CurrentUser -Force

GitHub Actions runs the same local check for toolkit script/config/test changes, and also runs the docs build plus npm audit.

Use -ErrorLogPath to give automated plan, WhatIf, or deployment tests a machine-readable JSONL artifact when the command fails:

Terminal window
$errorLog = ".\test-results\errors\deployment.jsonl"
New-AzureSqlVmToolkitDeployment `
-ConfigFile .\config.local.yaml `
-Plan `
-ErrorLogPath $errorLog

No file is created on success. On failure, use runId, mode, phase, resource.type, resource.name, and azureCorrelationId to group and diagnose runs. Keep the artifact private and review it before publishing it from CI.

Pester coverage verifies redaction, JSONL integrity, restrictive Unix permissions, concurrent writers, path aliases, phase tracking, Plan and WhatIf behavior, and preservation of the original error when diagnostic writing fails.