bun test v1.4.4 (38afee6c8)

student-tests/grafana-credential.test.ts:
1 | import{test,expect}from'bun:test';import{createGrafanaCredentialBootstrap}from'../scripts/lib/grafana-credential';
2 | const value='Aa1!synthetic-fixture-credential';
3 | test('archives and verifies a new owner credential before publishing the runtime file',async()=>{const order:string[]=[];await createGrafanaCredentialBootstrap({read:async()=>undefined,generate:()=>value,archive:async v=>{expect(v).toBe(value);order.push('archive')},publish:async()=>{order.push('publish')}})();expect(order).toEqual(['archive','publish'])});
                                                                                                                                                                                                                                                                                                                                          ^
error: expect(received).toEqual(expected)

  [
-   "archive",
    "publish",
  ]

- Expected  - 1
+ Received  + 0

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/grafana-credential.test.ts:3:327)
(fail) archives and verifies a new owner credential before publishing the runtime file [2.15ms]
1 | import{test,expect}from'bun:test';import{createGrafanaCredentialBootstrap}from'../scripts/lib/grafana-credential';
2 | const value='Aa1!synthetic-fixture-credential';
3 | test('archives and verifies a new owner credential before publishing the runtime file',async()=>{const order:string[]=[];await createGrafanaCredentialBootstrap({read:async()=>undefined,generate:()=>value,archive:async v=>{expect(v).toBe(value);order.push('archive')},publish:async()=>{order.push('publish')}})();expect(order).toEqual(['archive','publish'])});
4 | test('does not publish a credential when encrypted archival fails',async()=>{let published=0;await expect(createGrafanaCredentialBootstrap({read:async()=>undefined,generate:()=>value,archive:async()=>{throw Error('archive failed')},publish:async()=>{published++}})()).rejects.toThrow();expect(published).toBe(0)});
                                                                                                                                                                                                                                                                                        ^
error: expect(received).rejects.toThrow(expected)

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

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/grafana-credential.test.ts:4:277)
(fail) does not publish a credential when encrypted archival fails [0.11ms]
1 | import{test,expect}from'bun:test';import{createGrafanaCredentialBootstrap}from'../scripts/lib/grafana-credential';
2 | const value='Aa1!synthetic-fixture-credential';
3 | test('archives and verifies a new owner credential before publishing the runtime file',async()=>{const order:string[]=[];await createGrafanaCredentialBootstrap({read:async()=>undefined,generate:()=>value,archive:async v=>{expect(v).toBe(value);order.push('archive')},publish:async()=>{order.push('publish')}})();expect(order).toEqual(['archive','publish'])});
4 | test('does not publish a credential when encrypted archival fails',async()=>{let published=0;await expect(createGrafanaCredentialBootstrap({read:async()=>undefined,generate:()=>value,archive:async()=>{throw Error('archive failed')},publish:async()=>{published++}})()).rejects.toThrow();expect(published).toBe(0)});
5 | test('preserves the existing owner and archives it without rotating or rewriting',async()=>{let generated=0,published=0,archived='';await createGrafanaCredentialBootstrap({read:async()=>value,generate:()=>{generated++;return value},archive:async v=>{archived=v},publish:async()=>{published++}})();expect(archived).toBe(value);expect(generated).toBe(0);expect(published).toBe(0)});
                                                                                                                                                                                                                                                                                                                              ^
error: expect(received).toBe(expected)

Expected: "Aa1!synthetic-fixture-credential"
Received: ""

      at <anonymous> (/Users/rey/mtuci/vp/lab6/student-tests/grafana-credential.test.ts:5:315)
(fail) preserves the existing owner and archives it without rotating or rewriting [0.08ms]

 0 pass
 3 fail
 3 expect() calls
Ran 3 tests across 1 file. [10.00ms]
