bun test v1.4.4 (38afee6c8)

vp/lab6/student-tests/openobserve-account-http.test.ts:
3 | const request={path:'/api/default/service_accounts',method:'POST',body:{email:'fixture@example.invalid'},auth:'fixture-only'};
4 | const bytes=(value:string)=>new TextEncoder().encode(value);
5 | test('malformed one-time response is captured before JSON decoding fails',async()=>{
6 |  const captures:AccountCapture[]=[];const raw=bytes('{"token":"fixture-once",');
7 |  const call=createAccountHTTP({request:async()=>({status:200,chunks:(async function*(){yield raw})()}),capture:async r=>{captures.push(r)}},1000);
8 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(raw);expect(captures[0].status).toBe(200);
                                                                    ^
error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 0

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-account-http.test.ts:8:65)
(fail) malformed one-time response is captured before JSON decoding fails [0.60ms]
 8 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(raw);expect(captures[0].status).toBe(200);
 9 | });
10 | test('partial response is retained as uncertain when body reading fails',async()=>{
11 |  const captures:AccountCapture[]=[];const raw=bytes('{"token":"fixture-partial');
12 |  const call=createAccountHTTP({request:async()=>({status:200,chunks:(async function*(){yield raw;throw new Error('synthetic truncated body')})()}),capture:async r=>{captures.push(r)}},1000);
13 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(raw);expect(captures[0].complete).toBe(false);expect(captures[0].outcome).toBe('body_uncertain');
                                                                     ^
error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 0

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-account-http.test.ts:13:65)
(fail) partial response is retained as uncertain when body reading fails [0.11ms]
12 |  const call=createAccountHTTP({request:async()=>({status:200,chunks:(async function*(){yield raw;throw new Error('synthetic truncated body')})()}),capture:async r=>{captures.push(r)}},1000);
13 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(raw);expect(captures[0].complete).toBe(false);expect(captures[0].outcome).toBe('body_uncertain');
14 | });
15 | test('oversized response retains bounded available bytes before reporting its cap',async()=>{
16 |  const captures:AccountCapture[]=[];const call=createAccountHTTP({request:async()=>({status:200,chunks:(async function*(){yield bytes('123456')})()}),capture:async r=>{captures.push(r)}},4);
17 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(bytes('1234'));expect(captures[0].outcome).toBe('size_exceeded');expect(captures[0].complete).toBe(false);
                                                                     ^
error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 0

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-account-http.test.ts:17:65)
(fail) oversized response retains bounded available bytes before reporting its cap [0.09ms]
16 |  const captures:AccountCapture[]=[];const call=createAccountHTTP({request:async()=>({status:200,chunks:(async function*(){yield bytes('123456')})()}),capture:async r=>{captures.push(r)}},4);
17 |  await expect(call(request)).rejects.toThrow();expect(captures).toHaveLength(1);expect(captures[0].raw).toEqual(bytes('1234'));expect(captures[0].outcome).toBe('size_exceeded');expect(captures[0].complete).toBe(false);
18 | });
19 | test('network failure records uncertain request without retry',async()=>{
20 |  const captures:AccountCapture[]=[];let calls=0;const call=createAccountHTTP({request:async()=>{calls++;throw new Error('synthetic network failure')},capture:async r=>{captures.push(r)}},1000);
21 |  await expect(call(request)).rejects.toThrow();expect(calls).toBe(1);expect(captures).toHaveLength(1);expect(captures[0].status).toBeNull();expect(captures[0].outcome).toBe('network_uncertain');
                                                                                           ^
error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 0

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/openobserve-account-http.test.ts:21:87)
(fail) network failure records uncertain request without retry [0.07ms]
(pass) valid response is captured before it is returned to the create caller [0.08ms]

 1 pass
 4 fail
 12 expect() calls
Ran 5 tests across 1 file. [33.00ms]
