@@ -90,6 +90,12 @@ const verification: RecordingVerification = {
9090let rows : Record < string , Row [ ] > ;
9191let lockingOperations : string [ ] ;
9292
93+ function getJobRow ( ) : Row {
94+ const job = rows . jobs ?. [ 0 ] ;
95+ if ( ! job ) throw new Error ( "Missing job fixture" ) ;
96+ return job ;
97+ }
98+
9399function matches ( row : Row , condition ?: Condition ) : boolean {
94100 if ( ! condition ) return true ;
95101 if ( condition . op === "and" )
@@ -723,31 +729,31 @@ describe("retained-source retry policy", () => {
723729 it ( "pauses a repeatedly failing recording and retains its source" , async ( ) => {
724730 const attempt = await createAttempt ( ) ;
725731 await persistCommittedSource ( attempt , source ) ;
726- Object . assign ( rows . jobs [ 0 ] , { attemptCount : 5 } ) ;
732+ Object . assign ( getJobRow ( ) , { attemptCount : 5 } ) ;
727733 expect (
728734 await scheduleRetry ( {
729735 ...attempt ,
730736 errorCode : "output-invalid" ,
731737 errorMessage : "Timeline mismatch" ,
732738 } ) ,
733739 ) . toBe ( true ) ;
734- expect ( rows . jobs [ 0 ] ) . toMatchObject ( {
740+ expect ( rows . jobs ?. [ 0 ] ) . toMatchObject ( {
735741 state : "source-blocked" ,
736742 source,
737743 errorCode : "processing-retry-exhausted" ,
738744 errorMessage : "output-invalid: Timeline mismatch" ,
739745 } ) ;
740- expect ( rows . uploads [ 0 ] ) . toMatchObject ( { phase : "error" } ) ;
746+ expect ( rows . uploads ?. [ 0 ] ) . toMatchObject ( { phase : "error" } ) ;
741747 vi . setSystemTime ( new Date ( now . getTime ( ) + 24 * 60 * 60_000 ) ) ;
742748 expect (
743749 await claimProcessingAttempt ( { videoId, generation : attempt . generation } ) ,
744750 ) . toBeNull ( ) ;
745- expect ( rows . jobs [ 0 ] ?. attemptCount ) . toBe ( 5 ) ;
751+ expect ( rows . jobs ?. [ 0 ] ?. attemptCount ) . toBe ( 5 ) ;
746752 } ) ;
747753
748754 it ( "pauses an exhausted legacy job before downloading its source again" , async ( ) => {
749755 const attempt = await createAttempt ( ) ;
750- Object . assign ( rows . jobs [ 0 ] , {
756+ Object . assign ( getJobRow ( ) , {
751757 attemptCount : 220 ,
752758 state : "retry" ,
753759 leaseExpiresAt : null ,
@@ -756,24 +762,24 @@ describe("retained-source retry policy", () => {
756762 expect (
757763 await claimProcessingAttempt ( { videoId, generation : attempt . generation } ) ,
758764 ) . toBeNull ( ) ;
759- expect ( rows . jobs [ 0 ] ) . toMatchObject ( {
765+ expect ( rows . jobs ?. [ 0 ] ) . toMatchObject ( {
760766 attemptCount : 220 ,
761767 errorCode : "processing-retry-exhausted" ,
762768 } ) ;
763769 await ensureSegmentProcessingJob ( { videoId, userId } ) ;
764- expect ( rows . jobs [ 0 ] ) . toMatchObject ( {
770+ expect ( rows . jobs ?. [ 0 ] ) . toMatchObject ( {
765771 state : "source-blocked" ,
766772 errorCode : "processing-retry-exhausted" ,
767773 } ) ;
768774 } ) ;
769775
770776 it ( "does not interrupt an active final attempt" , async ( ) => {
771777 const attempt = await createAttempt ( ) ;
772- Object . assign ( rows . jobs [ 0 ] , { attemptCount : 5 } ) ;
778+ Object . assign ( getJobRow ( ) , { attemptCount : 5 } ) ;
773779 expect (
774780 await claimProcessingAttempt ( { videoId, generation : attempt . generation } ) ,
775781 ) . toBeNull ( ) ;
776- expect ( rows . jobs [ 0 ] ) . toMatchObject ( {
782+ expect ( rows . jobs ?. [ 0 ] ) . toMatchObject ( {
777783 state : "committing" ,
778784 attemptId : attempt . attemptId ,
779785 } ) ;
0 commit comments