@@ -147,21 +147,19 @@ async function template(id) {
147
147
}
148
148
149
149
//Testcase generator
150
- function testcase ( name , env , { prod = { } , test = { } , ...step } ) {
150
+ function testcase ( name , env , args ) {
151
+ const { prod = { } , test = { } , ...step } = JSON . parse ( JSON . stringify ( args ) )
151
152
const context = { prod, test} [ env ] ?? { }
152
153
if ( context . skip )
153
154
return null
154
- const result = { ...JSON . parse ( JSON . stringify ( step ) ) , ...context , name :`${ name } - ${ step . name ?? "(unnamed)" } ` }
155
- context . with ??= { }
155
+
156
+ Object . assign ( step . with , context . with ?? { } )
157
+ delete context . with
158
+ const result = { ...step , ...context , name :`${ name } - ${ step . name ?? "(unnamed)" } ` }
156
159
for ( const [ k , v ] of Object . entries ( result . with ) ) {
157
- if ( k in context . with )
158
- result . with [ k ] = context . with [ k ]
159
160
if ( ( env === "test" ) && ( secrets . $regex . test ( v ) ) )
160
161
result . with [ k ] = v . replace ( secrets . $regex , secrets [ v . match ( secrets . $regex ) ?. groups ?. secret ] )
161
162
}
162
- if ( ! result . with . base )
163
- delete result . with . base
164
- delete result . with . filename
165
163
166
164
if ( env === "prod" ) {
167
165
result . if = "${{ success() || failure() }}"
@@ -170,8 +168,12 @@ function testcase(name, env, {prod = {}, test = {}, ...step}) {
170
168
}
171
169
172
170
if ( env === "test" ) {
171
+ if ( ! result . with . base )
172
+ delete result . with . base
173
+ delete result . with . filename
173
174
Object . assign ( result . with , { use_mocked_data :"yes" , verify :"yes" } )
174
175
}
175
176
177
+ console . log ( arguments , result )
176
178
return result
177
179
}
0 commit comments