Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add spector test for jsonl #6201

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
tadelesh committed Mar 3, 2025
commit ffa0d7c77d0d3bdf11f2f2486ef1a135c95bb89d
13 changes: 3 additions & 10 deletions packages/http-specs/specs/streaming/jsonl/mockapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MockRequest, passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";
import { passOnSuccess, ScenarioMockApi } from "@typespec/spec-api";

export const Scenarios: Record<string, ScenarioMockApi> = {};

@@ -9,18 +9,11 @@ Scenarios.Streaming_Jsonl_Basic_send = passOnSuccess({
headers: {
"Content-Type": "application/jsonl",
},
body: '{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}',
body: Buffer.from('{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}'),
},
response: {
status: 204,
},
handler: (req: MockRequest) => {
req.expect.containsHeader("content-type", "application/jsonl");
req.expect.rawBodyEquals('{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}');
return {
status: 204,
};
},
kind: "MockApiDefinition",
});

@@ -31,7 +24,7 @@ Scenarios.Streaming_Jsonl_Basic_receive = passOnSuccess({
response: {
status: 200,
body: {
rawContent: '{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}',
rawContent: Buffer.from('{"desc": "one"}\n{"desc": "two"}\n{"desc": "three"}'),
contentType: "application/jsonl",
},
},
2 changes: 1 addition & 1 deletion packages/spector/src/server/server.ts
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ export class MockApiServer {
this.app.use(bodyParser.text({ type: "text/plain" }));
this.app.use(
bodyParser.raw({
type: ["application/octet-stream", "image/png"],
type: ["application/octet-stream", "image/png", "application/jsonl"],
limit: "10mb",
verify: rawBinaryBodySaver,
}),
Loading
Oops, something went wrong.