merge: integrate review-16-node-grant-failure
This commit is contained in:
commit
4537c6eb53
4 files changed
+24
-2
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { expect, spyOn, test } from "bun:test";
|
||||
import { handleWorkflowCommand } from "./workflow/index.js";
|
||||
import { parseArgs } from "../parser.js";
|
||||
import * as services from "../../domains/platform/services.js";
|
||||
test("failed grants retain gateway details and never report success", async () => {
|
||||
const grant = spyOn(services, "grantWorkflowNodes").mockResolvedValue({ success: false, saved: [], skipped: [], rawMessage: "permission denied" });
|
||||
try {
|
||||
for (const jsonMode of [false, true]) {
|
||||
const result = await handleWorkflowCommand(parseArgs(["workflow", "nodes", "grant", "code-js2", "--yes"]), { selectedCorp: { id: "corp", name: "test" }, jsonMode } as any);
|
||||
expect(result.exitCode).toBe(1);
|
||||
expect(result.stdout).not.toContain("节点权限已生效");
|
||||
if (jsonMode) expect(JSON.parse(result.stdout)).toMatchObject({ success: false, rawMessage: "permission denied" });
|
||||
else expect(result.stderr).toContain("permission denied");
|
||||
}
|
||||
} finally { grant.mockRestore(); }
|
||||
});
|
||||
@@ -606,9 +606,12 @@ async function handleGrantNodes(
|
||||
return {
|
||||
stdout: printJson(result, runtime.outputOptions),
|
||||
stderr: "",
|
||||
exitCode: 0,
|
||||
exitCode: result.success ? 0 : 1,
|
||||
};
|
||||
}
|
||||
if (!result.success) {
|
||||
return { stdout: "", stderr: `灰度节点开通失败: ${result.rawMessage || "网关拒绝了开通请求"}\n`, exitCode: 1 };
|
||||
}
|
||||
|
||||
const lines = [
|
||||
`====== 灰度节点开通结果 [${corp.name}] ======`,
|
||||
|
||||
Reference in new issue
Block a user