@@ -15,10 +15,10 @@ import {
1515 ValidateRequestData ,
1616 ValidateResponseData
1717} from 'codify-schemas' ;
18- import { ChildProcess , fork , spawn , SpawnOptions } from 'node:child_process' ;
18+ import { ChildProcess , SpawnOptions , fork , spawn } from 'node:child_process' ;
19+ import path from 'node:path' ;
1920
2021import { CodifyTestUtils } from './test-utils.js' ;
21- import path from 'node:path' ;
2222
2323const ajv = new Ajv2020 . default ( {
2424 strict : true
@@ -53,7 +53,7 @@ export class PluginTester {
5353 this . handleSudoRequests ( this . childProcess ) ;
5454 }
5555
56- async fullTest ( configs : ResourceConfig [ ] ) : Promise < void > {
56+ async fullTest ( configs : ResourceConfig [ ] , assertPlans ?: ( plans : PlanResponseData [ ] ) => void ) : Promise < void > {
5757 const initializeResult = await this . initialize ( ) ;
5858
5959 const unsupportedConfigs = configs . filter ( ( c ) =>
@@ -75,6 +75,10 @@ export class PluginTester {
7575 plans . push ( await this . plan ( config ) ) ;
7676 }
7777
78+ if ( assertPlans ) {
79+ assertPlans ( plans ) ;
80+ }
81+
7882 for ( const plan of plans ) {
7983 await this . apply ( {
8084 planId : plan . planId
@@ -97,25 +101,25 @@ ${JSON.stringify(unsuccessfulPlans, null, 2)}`
97101
98102 async uninstall ( configs : ResourceConfig [ ] ) {
99103 for ( const config of configs ) {
100- const { type , dependsOn, name, ...parameters } = config
104+ const { dependsOn, name, type , ...parameters } = config
101105
102106 await this . apply ( {
103107 plan : {
104108 operation : ResourceOperation . DESTROY ,
105- resourceType : config . type ,
106109 parameters : Object . entries ( parameters ) . map ( ( [ key , value ] ) => ( {
107110 name : key ,
108- previousValue : value ,
109111 newValue : null ,
110112 operation : ParameterOperation . REMOVE ,
113+ previousValue : value ,
111114 } ) ) ,
115+ resourceType : type ,
112116 }
113117 } ) ;
114118
115119 // Validate that the destroy was successful
116120 const validationPlan = await this . plan ( config ) ;
117121 if ( validationPlan . operation !== ResourceOperation . CREATE ) {
118- throw new Error ( `Resource ${ config . type } was not successfully destroyed.
122+ throw new Error ( `Resource ${ type } was not successfully destroyed.
119123Validation plan shows:
120124${ JSON . stringify ( validationPlan , null , 2 ) }
121125Previous config:
@@ -190,8 +194,6 @@ type CodifySpawnOptions = {
190194 *
191195 * @param cmd Command to run. Ex: `rm -rf`
192196 * @param opts Options for spawn
193- * @param secureMode Secure mode for sudo
194- * @param pluginName Optional plugin name so that stdout and stderr can be piped
195197 *
196198 * @see promiseSpawn
197199 * @see spawn
0 commit comments