MCPcopy
hub / github.com/langgenius/dify / startStub

Function startStub

cli/src/http/client.test.ts:17–29  ·  view source on GitHub ↗
(handler: (req: http.IncomingMessage, res: http.ServerResponse) => void)

Source from the content-addressed store, hash-verified

15type Stub = { url: string, stop: () => Promise<void> }
16
17function startStub(handler: (req: http.IncomingMessage, res: http.ServerResponse) => void): Promise<Stub> {
18 return new Promise((resolve, reject) => {
19 const server = http.createServer(handler)
20 server.listen(0, '127.0.0.1', () => {
21 const addr = server.address() as AddressInfo
22 resolve({
23 url: `http://127.0.0.1:${addr.port}`,
24 stop: () => new Promise<void>((res, rej) => server.close(err => err ? rej(err) : res())),
25 })
26 })
27 server.on('error', reject)
28 })
29}
30
31describe('http client', () => {
32 let mock: DifyMock

Callers 1

client.test.tsFile · 0.70

Calls 6

resFunction · 0.85
addressMethod · 0.80
resolveFunction · 0.50
listenMethod · 0.45
closeMethod · 0.45
onMethod · 0.45

Tested by

no test coverage detected