test(cli): 更新测试用例以模拟空环境变量场景

- 在 knowledge chat 相关测试中加入 BAILIAN_WORKSPACE_ID 为空的环境变量模拟
- 在 knowledge search 相关测试中加入 BAILIAN_WORKSPACE_ID 为空的环境变量模拟
- 将 knowledge 相关测试中的部分环境变量由 undefined 改为空字符串以更准确模拟环境场景
- 保持测试逻辑不变,确保非零退出码及错误提示的正确性
This commit is contained in:
zeyu.fz
2026-07-02 16:31:00 +08:00
parent 03541b4fd1
commit c6426e9e94
3 changed files with 32 additions and 26 deletions
@@ -56,17 +56,20 @@ describe("e2e: knowledge chat", () => {
});
test("缺少 --workspace-id 时非零退出并提示", async () => {
const { stderr, exitCode } = await runCli([
"knowledge",
"chat",
"--message",
"Hello",
"--agent-id",
"aid_test",
"--non-interactive",
"--output",
"json",
]);
const { stderr, exitCode } = await runCli(
[
"knowledge",
"chat",
"--message",
"Hello",
"--agent-id",
"aid_test",
"--non-interactive",
"--output",
"json",
],
{ BAILIAN_WORKSPACE_ID: "" },
);
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/workspace.*required/i);
});
@@ -47,17 +47,20 @@ describe("e2e: knowledge search", () => {
});
test("缺少 --workspace-id 时非零退出并提示", async () => {
const { stderr, exitCode } = await runCli([
"knowledge",
"search",
"--query",
"test",
"--agent-id",
"aid_test",
"--non-interactive",
"--output",
"json",
]);
const { stderr, exitCode } = await runCli(
[
"knowledge",
"search",
"--query",
"test",
"--agent-id",
"aid_test",
"--non-interactive",
"--output",
"json",
],
{ BAILIAN_WORKSPACE_ID: "" },
);
expect(exitCode).not.toBe(0);
expect(stderr).toMatch(/workspace.*required/i);
});
+4 -4
View File
@@ -80,10 +80,10 @@ describe("e2e: knowledge retrieve errors", () => {
"json",
],
{
DASHSCOPE_API_KEY: undefined,
DASHSCOPE_ACCESS_TOKEN: undefined,
ALIBABA_CLOUD_ACCESS_KEY_ID: undefined,
ALIBABA_CLOUD_ACCESS_KEY_SECRET: undefined,
DASHSCOPE_API_KEY: "",
DASHSCOPE_ACCESS_TOKEN: "",
ALIBABA_CLOUD_ACCESS_KEY_ID: "",
ALIBABA_CLOUD_ACCESS_KEY_SECRET: "",
BAILIAN_CONFIG_DIR: tmpdir(),
},
);