forked from mtusi2026/mtusi2026lab7
Prepare verified laboratory 7 implementation and evidence
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { parseOpenObserveResponse } from "../scripts/openobserve-response";
|
||||
for (const status of [401, 422, 500])
|
||||
test(`HTTP${status} text error preserves native HTTP outcome`, () => {
|
||||
expect(parseOpenObserveResponse(status, "Query deserialize error")).toEqual(
|
||||
{ status, data: null },
|
||||
);
|
||||
});
|
||||
test("HTTP200 JSON remains parsed", () => {
|
||||
expect(parseOpenObserveResponse(200, '{"code":200}')).toEqual({
|
||||
status: 200,
|
||||
data: { code: 200 },
|
||||
});
|
||||
});
|
||||
test("HTTP200 malformed success retains the status in its error", () => {
|
||||
expect(() => parseOpenObserveResponse(200, "invalid")).toThrow(
|
||||
"OPENOBSERVE_HTTP_200_INVALID_JSON",
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user