MCPcopy
hub / github.com/coder/mux / withTestOrpcServer

Function withTestOrpcServer

src/node/orpc/server.test.ts:218–236  ·  view source on GitHub ↗
(
  run: (server: TestOrpcServer) => Promise<T>,
  options: ServerOptions = {}
)

Source from the content-addressed store, hash-verified

216type ServerOptions = Omit<Parameters<typeof createOrpcServer>[0], "host" | "port" | "context">;
217
218async function withTestOrpcServer<T>(
219 run: (server: TestOrpcServer) => Promise<T>,
220 options: ServerOptions = {}
221): Promise<T> {
222 const server = await createOrpcServer({
223 host: "127.0.0.1",
224 port: 0,
225 // Tests in this file don't exercise context services unless explicitly supplied.
226 // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
227 context: {} as ORPCContext,
228 ...options,
229 });
230
231 try {
232 return await run(server);
233 } finally {
234 await server.close();
235 }
236}
237
238type OriginHeaders = Record<string, string> | ((server: TestOrpcServer) => Record<string, string>);
239

Callers 2

expectHttpOriginCaseFunction · 0.85

Calls 3

createOrpcServerFunction · 0.90
closeMethod · 0.65
runFunction · 0.50

Tested by

no test coverage detected