@@ -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,19 @@ 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' || replicationStatus === 'PROCESSING' ) ) {
120
+ continue ;
121
+ }
122
+
123
+ switch ( expectedOutcome ) {
124
+ case 'succeed' :
116
125
assert . notStrictEqual ( replicationStatus , 'FAILED' , `replication failed for object ${ objectName } ` ) ;
117
126
if ( replicationStatus === 'COMPLETED' ) {
118
127
return ;
119
128
}
120
- } else if ( replicate === 'fail to be' ) {
129
+ break ;
130
+ case 'fail' :
121
131
assert . notStrictEqual (
122
132
replicationStatus ,
123
133
'COMPLETED' ,
@@ -126,12 +136,20 @@ Then('the object should eventually {string} replicated', { timeout: 360_000 },
126
136
if ( replicationStatus === 'FAILED' ) {
127
137
return ;
128
138
}
139
+ break ;
140
+ case 'never happen' :
141
+ // When the replication is not expected to happen, replicationStatus is never set
142
+ assert . strictEqual (
143
+ replicationStatus , undefined ,
144
+ 'expected object to have no ReplicationStatus (should remain undefined)'
145
+ ) ;
146
+ break ;
129
147
}
130
- if ( replicationStatus === 'PENDING' || replicationStatus === 'PROCESSING' ) {
131
- continue ;
132
- }
133
148
}
134
- assert . fail ( `Timeout: Object '${ objectName } ' is still pending/processing after timeout` ) ;
149
+ if ( expectedOutcome === 'never happen' ) {
150
+ return ;
151
+ }
152
+ assert . fail ( `Timeout: Object '${ objectName } ' is still in pending/processing state after timeout` ) ;
135
153
} ) ;
136
154
137
155
Then (
0 commit comments