mirror of
https://github.com/kellymichels/zscripts-token-savers
synced 2026-10-07 07:18:18 +00:00
Part of #26. The toolkit had no automated tests at all - including for the functions that decide what goes into a deploy zip, which is where a dev .env reached production (#23). Phase 1 - the seam. Get-ZConfig read a hardcoded $PSScriptRoot\zconfig.json, so nothing config-dependent could be tested without touching the real config. Adds Get-ZConfigPath honoring $env:ZCONFIG (the bash port has always had this, so it also closes a parity gap) and Reset-ZConfigCache to drop the memoised config between fixtures. Deliberately did NOT convert the exit 1 paths to throw: that changes observed CLI output, and the pure functions don't need it. Phase 2 - 61 tests over the functions with no side effects: Get-ArchiveExcludes (common/python/vite/nextjs lists, deploy.exclude merging, dedupe, array shape), Get-ZConfig / Get-ZConfigPath / Get-ZProjectKeys / Get-ZProject (dash tolerance, underscore-key filtering, memoisation), Get-ZEdgeProject, Get-RemoteComposeDir, Get-Ec2Target / Get-Ec2Home, Get-LabelFromBuildJsonObj, Read-JsonBuildVersion. The suite is verified by mutation testing rather than assumed useful - six deliberate regressions were each introduced and confirmed to turn it red, including reintroducing the exact #23 bug and its inverse (backups silently dropping .env/uploads, which would produce restore points that cannot restore). Runs off a fixture config injected via ZCONFIG, so it never reads a real zconfig.json and passes on a machine that has never been configured.
90 lines
2.4 KiB
JSON
90 lines
2.4 KiB
JSON
{
|
|
"_comment": "Fixture config for the Pester suite. Not a real config - values are deliberately fake and are asserted against in ZHelpers.Tests.ps1. Keys starting with _ must be ignored by Get-ZProjectKeys.",
|
|
|
|
"ec2": {
|
|
"ip": "203.0.113.10",
|
|
"user": "testuser",
|
|
"pemKey": "C:\\fixtures\\test.pem",
|
|
"stackRoot": "/home/testuser/stack"
|
|
},
|
|
|
|
"paths": {
|
|
"temp": "C:\\fixtures\\temp",
|
|
"backupsLocal": "C:\\fixtures\\backups\\projects",
|
|
"backupsEc2": "C:\\fixtures\\backups\\ec2",
|
|
"scriptsRoot": "C:\\fixtures\\zscripts",
|
|
"oneDriveBackups": ""
|
|
},
|
|
|
|
"projects": {
|
|
"_note": "This underscore key must never appear as a project.",
|
|
|
|
"pyapp": {
|
|
"label": "Fixture Python App",
|
|
"kind": "python",
|
|
"localRoot": "C:\\fixtures\\pyapp",
|
|
"startModule": "pyapp.main",
|
|
"ports": { "dev": 8080 },
|
|
"domain": "pyapp.example.com",
|
|
"remote": {
|
|
"path": "/home/testuser/stack/pyapp",
|
|
"composeDir": "/home/testuser/stack/pyapp/docker",
|
|
"appService": "app"
|
|
},
|
|
"deploy": {
|
|
"zipName": "PyAppDeploy.zip",
|
|
"exclude": ["docs", "fixtures-extra"]
|
|
}
|
|
},
|
|
|
|
"viteapp": {
|
|
"label": "Fixture Vite Site",
|
|
"kind": "vite",
|
|
"localRoot": "C:\\fixtures\\viteapp",
|
|
"ports": { "dev": 5173 },
|
|
"domain": "www.example.com",
|
|
"remote": {
|
|
"path": "/home/testuser/stack/viteapp"
|
|
}
|
|
},
|
|
|
|
"nextapp": {
|
|
"label": "Fixture Next App",
|
|
"kind": "nextjs",
|
|
"localRoot": "C:\\fixtures\\nextapp",
|
|
"ports": { "dev": 4173, "prod": 3000 },
|
|
"remote": {
|
|
"path": "/home/testuser/stack/nextapp"
|
|
}
|
|
},
|
|
|
|
"edgeproxy": {
|
|
"label": "Fixture Edge",
|
|
"kind": "edge",
|
|
"localRoot": "C:\\fixtures\\edge",
|
|
"proxyContainer": "edge_proxy",
|
|
"remote": {
|
|
"path": "/home/testuser/stack/edge"
|
|
}
|
|
},
|
|
|
|
"dockeronly": {
|
|
"label": "Fixture Docker Stack",
|
|
"kind": "docker",
|
|
"localRoot": "C:\\fixtures\\dockeronly",
|
|
"remote": {
|
|
"path": "/home/testuser/stack/dockeronly"
|
|
}
|
|
},
|
|
|
|
"noports": {
|
|
"label": "Fixture No Dev Port",
|
|
"kind": "python",
|
|
"localRoot": "C:\\fixtures\\noports",
|
|
"remote": {
|
|
"path": "/home/testuser/stack/noports"
|
|
}
|
|
}
|
|
}
|
|
}
|