bun test v1.4.4 (38afee6c8)

student-tests/failover-proof.test.ts:
(pass) read current receipt contents and bind its stopped replica to the current attempt baseline [0.31ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject old operation receipt even when a file exists [0.20ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject foreign attempt receipt even when a file exists [0.05ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject wrong alias receipt even when a file exists [0.04ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject wrong container receipt even when a file exists [0.03ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject still running receipt even when a file exists [0.03ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject not initially running receipt even when a file exists [0.03ms]
2 | import{createFailoverReader,failoverReceiptPath,type FailoverProof,type ReplicaBaseline}from"../scripts/failover-proof";
3 | const operation="11111111-1111-4111-8111-111111111111",attempt="22222222-2222-4222-8222-222222222222";
4 | const baseline:ReplicaBaseline={api1:{container:"a".repeat(64),alias:"33333333-3333-4333-8333-333333333333"},api2:{container:"b".repeat(64),alias:"44444444-4444-4444-8444-444444444444"}};
5 | function valid():FailoverProof{return{operation_id:operation,attempt_id:attempt,service:"api1",target_alias:baseline.api1.alias,container:baseline.api1.container,before_running:true,running:false,volumes_removed:false};}
6 | test("read current receipt contents and bind its stopped replica to the current attempt baseline",async()=>{const calls:string[]=[];const r=await createFailoverReader({read:async(path)=>{calls.push(path);return valid();}})(operation,attempt,baseline);expect(r.proof.service).toBe("api1");expect(calls).toEqual([failoverReceiptPath(operation,attempt)]);});
7 | test.each([{name:"old operation",patch:{operation_id:attempt},code:"FAILOVER_WRONG_OPERATION"},{name:"foreign attempt",patch:{attempt_id:operation},code:"FAILOVER_WRONG_OPERATION"},{name:"wrong alias",patch:{target_alias:baseline.api2.alias},code:"FAILOVER_TARGET_MISMATCH"},{name:"wrong container",patch:{container:baseline.api2.container},code:"FAILOVER_TARGET_MISMATCH"},{name:"still running",patch:{running:true},code:"FAILOVER_STOP_NOT_PROVED"},{name:"not initially running",patch:{before_running:false},code:"FAILOVER_STOP_NOT_PROVED"},{name:"foreign service",patch:{service:"worker"},code:"FAILOVER_SERVICE_INVALID"}])("reject $name receipt even when a file exists",async({patch,code})=>{await expect(createFailoverReader({read:async()=>({...valid(),...patch})})(operation,attempt,baseline)).rejects.toThrow(code);});
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ^
error: expect(received).rejects.toThrow(expected)

Expected promise that rejects
Received promise that resolved: Promise { <resolved> }

      at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/failover-proof.test.ts:7:808)
(fail) reject foreign service receipt even when a file exists [0.03ms]
(pass) missing receipt preserves reader error instead of accepting older stable files [0.06ms]
(pass) required read port has no live filesystem fallback [0.02ms]

 3 pass
 7 fail
 11 expect() calls
Ran 10 tests across 1 file. [11.00ms]
