@@ -88,8 +88,11 @@ When('we run the job to replicate existing objects with status {string}',
8888        await  createAndRunPod ( this ,  podManifest ) ; 
8989    } ) ; 
9090
91- Then ( 'the object should eventually {string} replicated' ,  {  timeout : 360_000  } , 
92-     async  function  ( this : Zenko ,  replicate : 'be'  |  'fail to be' )  { 
91+ Then ( 'the object replication should eventually {string}' ,  {  timeout : 360_000  } , 
92+     async  function  ( 
93+         this : Zenko , 
94+         expectedOutcome : 'succeed'  |  'fail'  |  'never happen' 
95+     )  { 
9396        const  objectName  =  this . getSaved < string > ( 'objectName' ) ; 
9497        const  bucketSource  =  this . getSaved < string > ( 'bucketName' ) ; 
9598        const  startTime  =  Date . now ( ) ; 
@@ -110,13 +113,25 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
110113            } > ( response . stdout  ||  '{}' ) ; 
111114            assert ( parsed . ok ) ; 
112115            const  replicationStatus  =  parsed . result ?. ReplicationStatus ; 
116+             console . log ( `testing 0 ${ expectedOutcome }   - Response stdout:` ,  response . stdout ) ;             
117+             console . log ( `testing 1 ${ expectedOutcome }   - Full response:` ,  JSON . stringify ( response ,  null ,  2 ) ) ;             
118+             console . log ( `testing 2 ${ expectedOutcome }   - Parsed result:` ,  JSON . stringify ( parsed ,  null ,  2 ) ) ;             
119+             console . log ( `testing 3 ${ expectedOutcome }   - Parsed result:` ,  JSON . stringify ( parsed . result ,  null ,  2 ) ) ;             
120+             console . log ( `testing 4 ${ expectedOutcome }   - Replication status: ${ replicationStatus }  ` ) ;             
113121
114-             if  ( replicate  ===  'be' )  { 
122+             if  ( ( expectedOutcome  ===  'succeed'  ||  expectedOutcome  ===  'fail' )  &&  
123+                 ( replicationStatus  ===  'PENDING'  ||  replicationStatus  ===  'PROCESSING' ) )  { 
124+                 continue ; 
125+             } 
126+             
127+             switch  ( expectedOutcome )  { 
128+             case  'succeed' :
115129                assert . notStrictEqual ( replicationStatus ,  'FAILED' ,  `replication failed for object ${ objectName }  ` ) ; 
116130                if  ( replicationStatus  ===  'COMPLETED' )  { 
117131                    return ; 
118132                } 
119-             }  else  if  ( replicate  ===  'fail to be' )  { 
133+                 break ; 
134+             case  'fail' :
120135                assert . notStrictEqual ( 
121136                    replicationStatus , 
122137                    'COMPLETED' , 
@@ -125,12 +140,17 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
125140                if  ( replicationStatus  ===  'FAILED' )  { 
126141                    return ; 
127142                } 
143+                 break ; 
144+             case  'never happen' :
145+                 // When the replication is not expected to happen, replicationStatus is never set 
146+                 assert . strictEqual ( replicationStatus ,  undefined ,  'expected object to have no ReplicationStatus (should remain undefined)' ) ; 
147+                 break ; 
128148            } 
129-             if  ( replicationStatus  ===  'PENDING'  ||  replicationStatus  ===  'PROCESSING' )  { 
130-                 continue ; 
131-             } 
132149        } 
133-         assert . fail ( `Timeout: Object '${ objectName }  ' is still pending/processing after timeout` ) ; 
150+         if  ( expectedOutcome  ===  'never happen' )  { 
151+             return ; 
152+         } 
153+         assert . fail ( `Timeout: Object '${ objectName }  ' is still in pending/processing state after timeout` ) ; 
134154    } ) ; 
135155
136156Then ( 
0 commit comments