@@ -164,7 +164,8 @@ async function scaffoldTest(constraintId,context) {
164
164
message : `Choose the content for the negative test:` ,
165
165
choices : [
166
166
{ name : `Create new ${ constraintId } -INVALID.xml` , value : 'new' } ,
167
- { name : 'Select an existing content file to copy' , value : 'select' }
167
+ { name : 'Select an existing content file to copy' , value : 'select' } ,
168
+ { name : 'Point to an existing content file' , value : 'point' }
168
169
]
169
170
}
170
171
] ) ;
@@ -256,7 +257,7 @@ async function scaffoldTest(constraintId,context) {
256
257
fs . copyFileSync ( templatePath , newInvalidPath ) ;
257
258
invalidContent = `../content/${ model } -${ constraintId } -INVALID.xml` ;
258
259
}
259
- } else {
260
+ } else if ( useTemplate === 'select' ) {
260
261
const contentDir = path . join ( __dirname , '..' , '..' , 'src' , 'validations' , 'constraints' , 'content' ) ;
261
262
const contentFiles = fs . readdirSync ( contentDir ) . filter ( file => file . endsWith ( '.xml' ) ) ;
262
263
const { selectedContent } = await prompt ( [
@@ -278,6 +279,22 @@ async function scaffoldTest(constraintId,context) {
278
279
279
280
invalidContent = `../content/${ model } -${ constraintId } -INVALID.xml` ;
280
281
}
282
+ else {
283
+ const contentDir = path . join ( __dirname , '..' , '..' , 'src' , 'validations' , 'constraints' , 'content' ) ;
284
+ const contentFiles = fs . readdirSync ( contentDir ) . filter ( file => file . endsWith ( '.xml' ) ) ;
285
+ const { selectedContent } = await prompt ( [
286
+ {
287
+ type : 'list' ,
288
+ name : 'selectedContent' ,
289
+ message : 'Select an existing content file to point to:' ,
290
+ choices : contentFiles
291
+ }
292
+ ] ) ;
293
+ const selectedContentPath = path . join ( contentDir , selectedContent ) ;
294
+ const selectedContentTarget = selectedContentPath . split ( "/" ) . pop ( ) ;
295
+ console . log ( `Pointed invalid test for ${ constraintId } to ${ selectedContentTarget } ` ) ;
296
+ invalidContent = `../content/${ selectedContentTarget } ` ;
297
+ }
281
298
282
299
const positivetestCase = {
283
300
'test-case' : {
0 commit comments