Files
wehub-resource-sync e0e362d700
SDK Tests / SDK CI (push) Blocked by required conditions
SDK Tests / changes (push) Successful in 2m29s
Real E2E Tests / changes (push) Successful in 2m29s
SDK Tests / Python SDK Tests (sandbox) (push) Waiting to run
SDK Tests / CLI Quality (push) Waiting to run
SDK Tests / CLI Tests (push) Waiting to run
SDK Tests / Python SDK Quality (code-interpreter) (push) Waiting to run
SDK Tests / Python SDK Quality (sandbox) (push) Waiting to run
SDK Tests / Python SDK Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / JavaScript SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Kotlin SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (code-interpreter) (push) Waiting to run
SDK Tests / C# SDK Quality And Tests (sandbox) (push) Waiting to run
SDK Tests / Go SDK Quality And Tests (push) Waiting to run
Deploy Docs Pages / build (push) Has been cancelled
Deploy Docs Pages / deploy (push) Has been cancelled
Real E2E Tests / JavaScript E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Python E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Java E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / C# E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Go E2E (docker bridge) (push) Has been cancelled
Real E2E Tests / Real E2E CI (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:33 +08:00

67 lines
1.8 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { CommandsAdapter, createExecdClient } from "../dist/internal.js";
function createTransportAdapter({ body = "", cursor = "42" } = {}) {
const client = createExecdClient({
baseUrl: "http://127.0.0.1:8080",
async fetch(request) {
assert.equal(new URL(request.url).pathname, "/command/cmd-1/logs");
assert.equal(new URL(request.url).searchParams.get("cursor"), "42");
return new Response(body, {
status: 200,
headers: {
"content-type": "text/plain",
"EXECD-COMMANDS-TAIL-CURSOR": cursor,
},
});
},
});
return new CommandsAdapter(client, {
baseUrl: "http://127.0.0.1:8080",
});
}
function createNullBodyAdapter({ cursor = "42" } = {}) {
return new CommandsAdapter(
{
async GET() {
return {
data: null,
error: undefined,
response: new Response(null, {
status: 200,
headers: {
"content-type": "text/plain",
"EXECD-COMMANDS-TAIL-CURSOR": cursor,
},
}),
};
},
},
{
baseUrl: "http://127.0.0.1:8080",
},
);
}
test("CommandsAdapter.getBackgroundCommandLogs accepts an empty transport body", async () => {
const adapter = createTransportAdapter({ body: "", cursor: "42" });
const logs = await adapter.getBackgroundCommandLogs("cmd-1", 42);
assert.equal(logs.content, "");
assert.equal(logs.cursor, 42);
});
test("CommandsAdapter.getBackgroundCommandLogs accepts a null parsed body on 200 responses", async () => {
const adapter = createNullBodyAdapter({ cursor: "42" });
const logs = await adapter.getBackgroundCommandLogs("cmd-1", 42);
assert.equal(logs.content, "");
assert.equal(logs.cursor, 42);
});