By mameikagou. Reviewed at 0966b4b (comment on #297); squashed onto
origin/main dc59000 with the version bump.
Run at this tree: HOME=$(mktemp -d) bun test: 2083 pass, 0 fail;
bun scripts/check.mjs ok. Earlier, at 0966b4b with main's
packages/devin/index.mjs put back, the three new or changed tests
(empty-reply, error-after-metadata, metadata-only) were red.
Not tried: a real Devin account answering with an empty reply.
Co-authored-by: mameikagou <mameikagou@users.noreply.github.com>
25 lines
953 B
JavaScript
25 lines
953 B
JavaScript
import { expect, test } from "bun:test"
|
|
import { readFile } from "node:fs/promises"
|
|
import { _internal } from "./index.mjs"
|
|
|
|
const captured = new URL("./testdata/empty-reply.bin", import.meta.url)
|
|
|
|
test("Devin's usage-only reply fails before a successful stream is opened", async () => {
|
|
const raw = await readFile(captured)
|
|
const real = globalThis.fetch
|
|
globalThis.fetch = async () => new Response(raw)
|
|
try {
|
|
for (const stream of [true, false]) {
|
|
const response = await _internal.complete(
|
|
{ key: "test", server: "https://devin.test", families: _internal.familiesOf(_internal.SNAPSHOT) },
|
|
{ model: "gemini-4-argon", stream, messages: [{ role: "user", content: "?" }] },
|
|
)
|
|
expect(response.status).toBe(502)
|
|
expect((await response.json()).error.message).toContain("empty reply")
|
|
expect(response.headers.get("X-Magpie-Sign-In")).toBe("kept")
|
|
}
|
|
} finally {
|
|
globalThis.fetch = real
|
|
}
|
|
})
|