Public dry run dryrun-0b6a82183be2
Source commit: 0b6a82183be25780b308c75442a9b5f602f727d4
This commit is contained in:
parent
8c0c336ae9
commit
5386bb851f
16 changed files with 608 additions and 95 deletions
77
scripts/cli-output-mode-smoke.js
Normal file
77
scripts/cli-output-mode-smoke.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
const assert = require("assert");
|
||||
const cp = require("child_process");
|
||||
const path = require("path");
|
||||
|
||||
const repo = path.resolve(__dirname, "..");
|
||||
const project = path.join(repo, "examples/launch-build-demo");
|
||||
|
||||
function disasmer(args, env = {}) {
|
||||
return cp.execFileSync(
|
||||
"cargo",
|
||||
["run", "-q", "-p", "disasmer-cli", "--bin", "disasmer", "--", ...args],
|
||||
{
|
||||
cwd: repo,
|
||||
encoding: "utf8",
|
||||
env: {
|
||||
...process.env,
|
||||
...env,
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function json(args, env) {
|
||||
return JSON.parse(disasmer(args, env));
|
||||
}
|
||||
|
||||
function assertHuman(name, output, requiredPatterns) {
|
||||
assert(
|
||||
!output.trimStart().startsWith("{"),
|
||||
`${name} default output should be human-readable text, not JSON`
|
||||
);
|
||||
for (const pattern of requiredPatterns) {
|
||||
assert.match(output, pattern, `${name} human output missing ${pattern}`);
|
||||
}
|
||||
}
|
||||
|
||||
const loginHuman = disasmer(["login", "--coordinator", "https://coord.example.test"]);
|
||||
assertHuman("login", loginHuman, [
|
||||
/Disasmer login/,
|
||||
/flow: device/,
|
||||
/verify: https:\/\/coord\.example\.test\/auth\/device/,
|
||||
]);
|
||||
|
||||
const loginJson = json(["login", "--coordinator", "https://coord.example.test", "--json"]);
|
||||
assert.strictEqual(loginJson.coordinator, "https://coord.example.test");
|
||||
assert(loginJson.human_flow.Device);
|
||||
|
||||
const doctorHuman = disasmer(["doctor"]);
|
||||
assertHuman("doctor", doctorHuman, [
|
||||
/Disasmer doctor/,
|
||||
/dependencies:/,
|
||||
/auth:/,
|
||||
/node capabilities:/,
|
||||
]);
|
||||
|
||||
const authJson = json(["auth", "status", "--json"], {
|
||||
DISASMER_TOKEN: "token",
|
||||
DISASMER_TOKEN_EXPIRES_AT: "2026-07-04T00:00:00Z",
|
||||
});
|
||||
assert.strictEqual(authJson.session.kind, "human");
|
||||
assert.strictEqual(authJson.session.token_expiry_posture, "expires_at");
|
||||
assert.strictEqual(authJson.session.expires_at, "2026-07-04T00:00:00Z");
|
||||
|
||||
const inspectHuman = disasmer(["bundle", "inspect", "--project", project]);
|
||||
assertHuman("bundle inspect", inspectHuman, [
|
||||
/Disasmer bundle inspect/,
|
||||
/bundle: sha256:/,
|
||||
/environments:/,
|
||||
]);
|
||||
|
||||
const inspectJson = json(["bundle", "inspect", "--project", project, "--json"]);
|
||||
assert.strictEqual(inspectJson.project, project);
|
||||
assert.match(inspectJson.metadata.identity, /^sha256:/);
|
||||
|
||||
console.log("CLI output mode smoke passed");
|
||||
Loading…
Add table
Add a link
Reference in a new issue