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