crosscode uninstall/export/purge <church> [product ...]: with products named only those go and the church keeps the others; naming every product it still has removes the church (folder and app user), so the last product to go takes the church with it. The report gives products and remaining. Uninstalling cross-events-demo's Events removed its Accounts too, which the Hub still showed as live. Contracts 1.16.0: optional products on export/uninstall/purge, PRODUCT_UNINSTALL_MIN_AGENT. Agent 1.5.0 passes them to crosscode. The Website plan moves to contracts 1.17.0 / Hub 2.13.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.4 KiB
Bash
70 lines
2.4 KiB
Bash
#!/usr/bin/env bats
|
|
# --json reports (lib/report.sh) and the argument checks of the new commands (what needs a server
|
|
# is tested on a VM).
|
|
|
|
bats_require_minimum_version 1.5.0
|
|
|
|
setup() {
|
|
export CROSSCODE_NO_UPDATE=1
|
|
CC="$BATS_TEST_DIRNAME/../crosscode"
|
|
}
|
|
|
|
json() { node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{const v=process.argv[1].split(".").reduce((o,k)=>o==null?o:o[k],JSON.parse(s));process.stdout.write(typeof v==="object"?JSON.stringify(v):String(v))})' "$1"; }
|
|
|
|
@test "--json: one report on stdout, the log on stderr" {
|
|
run --separate-stderr bash "$CC" help --json
|
|
[ "$status" -eq 0 ]
|
|
[ "$(printf '%s' "$output" | json schema)" = "crosscode.script-report/1" ]
|
|
[ "$(printf '%s' "$output" | json status)" = "succeeded" ]
|
|
[ "$(printf '%s' "$output" | json command)" = "help" ]
|
|
[[ "$stderr" == *"crosscode deploy <church>"* ]]
|
|
}
|
|
|
|
@test "--json on a failure: status failed and the reason" {
|
|
run --separate-stderr bash "$CC" uninstall hope --json
|
|
[ "$status" -eq 1 ]
|
|
[ "$(printf '%s' "$output" | json status)" = "failed" ]
|
|
[[ "$(printf '%s' "$output" | json message)" == *"--confirm hope"* ]]
|
|
}
|
|
|
|
@test "--config must be an existing JSON file" {
|
|
run bash "$CC" status --config /nonexistent.json
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"no file /nonexistent.json"* ]]
|
|
echo 'not json' > "$BATS_TEST_TMPDIR/c.json"
|
|
run bash "$CC" status --config "$BATS_TEST_TMPDIR/c.json"
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"isn't JSON"* ]]
|
|
}
|
|
|
|
@test "uninstall and purge need --confirm with the church's own name" {
|
|
run bash "$CC" uninstall hope
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"add --confirm hope"* ]]
|
|
run bash "$CC" uninstall hope --confirm other
|
|
[ "$status" -eq 1 ]
|
|
run bash "$CC" purge hope
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"add --confirm hope"* ]]
|
|
}
|
|
|
|
@test "export needs an absolute .zip path" {
|
|
run bash "$CC" export hope --out relative.zip
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"absolute path ending in .zip"* ]]
|
|
}
|
|
|
|
@test "install --frp needs the ports from the Hub" {
|
|
run bash "$CC" install hope --products events --domain hope.co.za --frp
|
|
[ "$status" -eq 1 ]
|
|
[[ "$output" == *"--frp needs --api-port and --web-port"* ]]
|
|
}
|
|
|
|
@test "help lists the new commands" {
|
|
run bash "$CC" help
|
|
[[ "$output" == *"crosscode uninstall <church> [product …] --confirm <church>"* ]]
|
|
[[ "$output" == *"--json"* ]]
|
|
run bash "$CC" help export
|
|
[[ "$output" == *"crosscode.church-export/1"* ]]
|
|
}
|