84 tests in collectors/tests, run with Invoke-CollectorTests.ps1 (~15 s, PowerShell 7.2+ and Pester 5.5+): - Module.Tests: the shared module (property lookup, time format, config/lookback, sent-run state and pruning, dry runs, exit codes, 401 detection) - Veeam/Mars/Wsb/Vb365.Tests: each collector run in its own process against its mock and a stand-in ingest API, asserting the behaviours confirmed on real servers: VBR 13 live schedule, copy jobs, MARS UTC times and ErrorCode 0, WSB culture-formatted times and nested VMs, VB365 organization mapping, log prefixes and retries, state and resending, rejected keys - Installers.Tests: config, files and scheduled task from each installer, with stand-ins for icacls / Task Scheduler / the key prompt Collectors run under the test runner's PowerShell, or another shell via -CollectorShell (e.g. powershell.exe, to test under Windows PowerShell 5.1 like the MARS, WSB and VB365 servers). The mocks take their "now" from MOCK_NOW so expectations can't drift with the clock; the WSB mock gains -RunningJobFinished for the running-to-finished case. Each of 12 past bugs, put back one at a time, fails the test for its behaviour (and the runner exits 1). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Collector tests
Pester tests for the collectors, the shared module and the installers. Each collector runs against
its mock (collectors/<name>/tests/Mock*.ps1, built from real servers' diagnostic output) and a
stand-in for the ingest API, so no backup product or dashboard is needed.
Install-Module Pester -MinimumVersion 5.5 -Scope CurrentUser # once
./collectors/tests/Invoke-CollectorTests.ps1 # everything, ~15 s
./collectors/tests/Invoke-CollectorTests.ps1 -Path ./collectors/tests/Wsb.Tests.ps1
Needs PowerShell 7.2+ to run the tests. Collectors run in their own process, under the same PowerShell by default. On Windows, run them under Windows PowerShell 5.1, as the MARS, WSB and VB365 servers do:
./collectors/tests/Invoke-CollectorTests.ps1 -CollectorShell powershell.exe
The runner exits non-zero if anything fails.
What's covered
| File | Checks |
|---|---|
Module.Tests.ps1 |
BackupDashboard.Collector.psm1: property lookup, time format, config and lookback, state (recording sent runs, pruning), dry runs, exit codes, 401 detection |
Veeam.Tests.ps1 |
Next run from the live schedule (VBR 13), none for copy/disabled jobs; copy-job worker sessions; statuses and messages; state and resending; rejected key; missing config |
Mars.Tests.ps1 |
UTC job times; ErrorCode 0 isn't an error; failed files → warning; next run from the schedule; JobName; state |
Wsb.Tests.ps1 |
Culture-formatted times (en-US and en-GB); VMs nested in VirtualMachineList; HRESULTs; failure log only when relevant; running → finished merging on start time |
Vb365.Tests.ps1 |
Organization → company mapping; [Warning]/[Failed] log prefixes; retries; "187.2 MB" sizes; state |
Installers.Tests.ps1 |
Config written (incl. the VB365 map), files copied (collector + module), task registered (shell, interval, SYSTEM), refusals before changing anything |
Each of these was a real bug or a real-server finding. To check the suite still catches them,
put one back (e.g. read $Job.ScheduleOptions.NextRun instead of GetScheduleOptions() in the
Veeam collector) and run the tests: they should fail.
Adding a collector
- Write
collectors/<name>/tests/Mock<Name>.ps1from the product's diagnostic output, taking its time from$env:MOCK_NOWlike the others. - Add
<name>toInvoke-Collector'sValidateSetinTestHelpers.psm1. - Add
<Name>.Tests.ps1, oneItper behaviour confirmed on a real server.