@@ -89,8 +89,11 @@ When('the job to replicate existing objects with status {string} is executed',
89
89
await createAndRunPod ( this , podManifest ) ;
90
90
} ) ;
91
91
92
- Then ( 'the object should eventually {string} replicated' , { timeout : 360_000 } ,
93
- async function ( this : Zenko , replicate : 'be' | 'fail to be' ) {
92
+ Then ( 'the object replication should eventually {string}' , { timeout : 360_000 } ,
93
+ async function (
94
+ this : Zenko ,
95
+ expectedOutcome : 'succeed' | 'fail' | 'never happen'
96
+ ) {
94
97
const objectName = this . getSaved < string > ( 'objectName' ) ;
95
98
const bucketSource = this . getSaved < string > ( 'bucketName' ) ;
96
99
const startTime = Date . now ( ) ;
@@ -112,12 +115,22 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
112
115
assert ( parsed . ok ) ;
113
116
const replicationStatus = parsed . result ?. ReplicationStatus ;
114
117
115
- if ( replicate === 'be' ) {
118
+ if ( ( expectedOutcome === 'succeed' || expectedOutcome === 'fail' ) &&
119
+ ( replicationStatus === 'PENDING' ||
120
+ replicationStatus === 'PROCESSING' ||
121
+ replicationStatus === undefined // If replication hasn't started, status is still undefined
122
+ ) ) {
123
+ continue ;
124
+ }
125
+
126
+ switch ( expectedOutcome ) {
127
+ case 'succeed' :
116
128
assert . notStrictEqual ( replicationStatus , 'FAILED' , `replication failed for object ${ objectName } ` ) ;
117
129
if ( replicationStatus === 'COMPLETED' ) {
118
130
return ;
119
131
}
120
- } else if ( replicate === 'fail to be' ) {
132
+ break ;
133
+ case 'fail' :
121
134
assert . notStrictEqual (
122
135
replicationStatus ,
123
136
'COMPLETED' ,
@@ -126,12 +139,20 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
126
139
if ( replicationStatus === 'FAILED' ) {
127
140
return ;
128
141
}
142
+ break ;
143
+ case 'never happen' :
144
+ // When the replication is not expected to happen, replicationStatus is never set
145
+ assert . strictEqual (
146
+ replicationStatus , undefined ,
147
+ 'expected object to have no ReplicationStatus (should remain undefined)'
148
+ ) ;
149
+ break ;
129
150
}
130
- if ( replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING' ) {
131
- continue ;
132
- }
133
151
}
134
- assert . fail ( `Timeout: Object '${ objectName } ' is still pending/processing after timeout` ) ;
152
+ if ( expectedOutcome === 'never happen' ) {
153
+ return ;
154
+ }
155
+ assert . fail ( `Timeout: Object '${ objectName } ' is still in pending/processing state after timeout` ) ;
135
156
} ) ;
136
157
137
158
Then (
0 commit comments