11import Ajv from 'ajv' ;
2+ import chalk from 'chalk' ;
23import {
34 ApplyRequestData ,
45 ImportRequestData ,
@@ -75,6 +76,9 @@ export class PluginTester {
7576 skipUninstall = false ,
7677 } = options ?? { }
7778
79+ const ids = configs . map ( ( c ) => c . name ? `${ c . type } .${ c . name } ` : c . type ) . join ( ',' )
80+
81+ console . info ( chalk . cyan ( `Testing initialization for ${ ids } ...` ) )
7882 const initializeResult = await this . initialize ( ) ;
7983
8084 const unsupportedConfigs = configs . filter ( ( c ) =>
@@ -84,13 +88,15 @@ export class PluginTester {
8488 throw new Error ( `The plugin does not support the following configs supplied:\n ${ JSON . stringify ( unsupportedConfigs , null , 2 ) } \n Initialize result: ${ JSON . stringify ( initializeResult ) } ` )
8589 }
8690
91+ console . info ( chalk . cyan ( `Testing validate for ${ ids } ...` ) )
8792 const validate = await this . validate ( { configs } ) ;
8893
8994 const invalidConfigs = validate . resourceValidations . filter ( ( v ) => ! v . isValid )
9095 if ( invalidConfigs . length > 0 ) {
9196 throw new Error ( `The following configs did not validate:\n ${ JSON . stringify ( invalidConfigs , null , 2 ) } ` )
9297 }
9398
99+ console . info ( chalk . cyan ( `Testing plan for ${ ids } ...` ) )
94100 const plans = [ ] ;
95101 for ( const config of configs ) {
96102 plans . push ( await this . plan ( {
@@ -104,6 +110,7 @@ export class PluginTester {
104110 await options . validatePlan ( plans ) ;
105111 }
106112
113+ console . info ( chalk . cyan ( `Testing apply for ${ ids } ...` ) )
107114 for ( const plan of plans ) {
108115 await this . apply ( {
109116 planId : plan . planId
@@ -114,6 +121,7 @@ export class PluginTester {
114121 await options . validateApply ( plans ) ;
115122 }
116123
124+ console . info ( chalk . cyan ( `Testing import for ${ ids } ...` ) )
117125 const importResults = [ ] ;
118126 for ( const config of configs ) {
119127 const importResult = await this . import ( { config } )
@@ -125,6 +133,8 @@ export class PluginTester {
125133 }
126134
127135 if ( options ?. testModify ) {
136+ console . info ( chalk . cyan ( `Testing modify for ${ ids } ...` ) )
137+
128138 const modifyPlans = [ ] ;
129139 for ( const config of options . testModify . modifiedConfigs ) {
130140 modifyPlans . push ( await this . plan ( {
@@ -165,8 +175,10 @@ ${JSON.stringify(modifyPlans, null, 2)}`)
165175 async uninstall ( configs : ResourceConfig [ ] , options ?: {
166176 validateDestroy ?: ( plans : PlanResponseData [ ] ) => Promise < void > | void
167177 } ) {
168- const plans = [ ] ;
178+ const ids = configs . map ( ( c ) => c . name ? `${ c . type } .${ c . name } ` : c . type ) . join ( ',' )
179+ console . info ( chalk . cyan ( `Testing destroy for ${ ids } ...` ) )
169180
181+ const plans = [ ] ;
170182 for ( const config of configs ) {
171183 plans . push ( await this . plan ( {
172184 desired : undefined ,
@@ -177,7 +189,7 @@ ${JSON.stringify(modifyPlans, null, 2)}`)
177189
178190 for ( const plan of plans ) {
179191 if ( plan . operation !== ResourceOperation . DESTROY ) {
180- throw new Error ( `Expect resource operation to be 'destory ' but instead received plan: \n ${ JSON . stringify ( plan , null , 2 ) } ` )
192+ throw new Error ( `Expect resource operation to be 'destroy ' but instead received plan: \n ${ JSON . stringify ( plan , null , 2 ) } ` )
181193 }
182194
183195 await this . apply ( {
0 commit comments