codify-plugin-test 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin-tester.d.ts +2 -1
- package/dist/plugin-tester.js +12 -6
- package/dist/plugin-tester.js.map +1 -1
- package/package.json +1 -1
- package/src/plugin-tester.ts +15 -9
- package/test/plugin-tester.test.ts +31 -3
package/dist/plugin-tester.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ import { ChildProcess } from 'node:child_process';
|
|
|
4
4
|
export declare class PluginTester {
|
|
5
5
|
childProcess: ChildProcess;
|
|
6
6
|
constructor(pluginPath: string);
|
|
7
|
-
fullTest(configs: ResourceConfig[]): Promise<void>;
|
|
7
|
+
fullTest(configs: ResourceConfig[], assertPlans?: (plans: PlanResponseData[]) => void): Promise<void>;
|
|
8
8
|
uninstall(configs: ResourceConfig[]): Promise<void>;
|
|
9
9
|
initialize(): Promise<InitializeResponseData>;
|
|
10
10
|
validate(data: ValidateRequestData): Promise<ValidateResponseData>;
|
|
11
11
|
plan(data: PlanRequestData): Promise<PlanResponseData>;
|
|
12
12
|
apply(data: ApplyRequestData): Promise<void>;
|
|
13
|
+
kill(): void;
|
|
13
14
|
private handleSudoRequests;
|
|
14
15
|
}
|
package/dist/plugin-tester.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
2
2
|
import { IpcMessageSchema, MessageCmd, ParameterOperation, ResourceOperation, SpawnStatus, SudoRequestDataSchema } from 'codify-schemas';
|
|
3
3
|
import { fork, spawn } from 'node:child_process';
|
|
4
|
-
import { CodifyTestUtils } from './test-utils.js';
|
|
5
4
|
import path from 'node:path';
|
|
5
|
+
import { CodifyTestUtils } from './test-utils.js';
|
|
6
6
|
const ajv = new Ajv2020.default({
|
|
7
7
|
strict: true
|
|
8
8
|
});
|
|
@@ -21,7 +21,7 @@ export class PluginTester {
|
|
|
21
21
|
});
|
|
22
22
|
this.handleSudoRequests(this.childProcess);
|
|
23
23
|
}
|
|
24
|
-
async fullTest(configs) {
|
|
24
|
+
async fullTest(configs, assertPlans) {
|
|
25
25
|
const initializeResult = await this.initialize();
|
|
26
26
|
const unsupportedConfigs = configs.filter((c) => !initializeResult.resourceDefinitions.some((rd) => rd.type === c.type));
|
|
27
27
|
if (unsupportedConfigs.length > 0) {
|
|
@@ -36,6 +36,9 @@ export class PluginTester {
|
|
|
36
36
|
for (const config of configs) {
|
|
37
37
|
plans.push(await this.plan(config));
|
|
38
38
|
}
|
|
39
|
+
if (assertPlans) {
|
|
40
|
+
assertPlans(plans);
|
|
41
|
+
}
|
|
39
42
|
for (const plan of plans) {
|
|
40
43
|
await this.apply({
|
|
41
44
|
planId: plan.planId
|
|
@@ -53,22 +56,22 @@ ${JSON.stringify(unsuccessfulPlans, null, 2)}`);
|
|
|
53
56
|
}
|
|
54
57
|
async uninstall(configs) {
|
|
55
58
|
for (const config of configs) {
|
|
56
|
-
const {
|
|
59
|
+
const { dependsOn, name, type, ...parameters } = config;
|
|
57
60
|
await this.apply({
|
|
58
61
|
plan: {
|
|
59
62
|
operation: ResourceOperation.DESTROY,
|
|
60
|
-
resourceType: config.type,
|
|
61
63
|
parameters: Object.entries(parameters).map(([key, value]) => ({
|
|
62
64
|
name: key,
|
|
63
|
-
previousValue: value,
|
|
64
65
|
newValue: null,
|
|
65
66
|
operation: ParameterOperation.REMOVE,
|
|
67
|
+
previousValue: value,
|
|
66
68
|
})),
|
|
69
|
+
resourceType: type,
|
|
67
70
|
}
|
|
68
71
|
});
|
|
69
72
|
const validationPlan = await this.plan(config);
|
|
70
73
|
if (validationPlan.operation !== ResourceOperation.CREATE) {
|
|
71
|
-
throw new Error(`Resource ${
|
|
74
|
+
throw new Error(`Resource ${type} was not successfully destroyed.
|
|
72
75
|
Validation plan shows:
|
|
73
76
|
${JSON.stringify(validationPlan, null, 2)}
|
|
74
77
|
Previous config:
|
|
@@ -100,6 +103,9 @@ ${JSON.stringify(config, null, 2)}`);
|
|
|
100
103
|
data,
|
|
101
104
|
});
|
|
102
105
|
}
|
|
106
|
+
kill() {
|
|
107
|
+
this.childProcess.kill();
|
|
108
|
+
}
|
|
103
109
|
handleSudoRequests(process) {
|
|
104
110
|
process.on('message', async (message) => {
|
|
105
111
|
if (!ipcMessageValidator(message)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-tester.js","sourceRoot":"","sources":["../src/plugin-tester.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAGL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAIlB,iBAAiB,EACjB,WAAW,EAEX,qBAAqB,EAGtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin-tester.js","sourceRoot":"","sources":["../src/plugin-tester.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAGL,gBAAgB,EAChB,UAAU,EACV,kBAAkB,EAIlB,iBAAiB,EACjB,WAAW,EAEX,qBAAqB,EAGtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAA8B,IAAI,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,GAAG,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC;IAC9B,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC1D,MAAM,oBAAoB,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEhE,MAAM,OAAO,YAAY;IACvB,YAAY,CAAc;IAO1B,YAAY,UAAkB;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,U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K;aAC7D,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/plugin-tester.ts
CHANGED
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
ValidateRequestData,
|
|
16
16
|
ValidateResponseData
|
|
17
17
|
} from 'codify-schemas';
|
|
18
|
-
import { ChildProcess, fork, spawn
|
|
18
|
+
import { ChildProcess, SpawnOptions, fork, spawn } from 'node:child_process';
|
|
19
|
+
import path from 'node:path';
|
|
19
20
|
|
|
20
21
|
import { CodifyTestUtils } from './test-utils.js';
|
|
21
|
-
import path from 'node:path';
|
|
22
22
|
|
|
23
23
|
const ajv = new Ajv2020.default({
|
|
24
24
|
strict: true
|
|
@@ -53,7 +53,7 @@ export class PluginTester {
|
|
|
53
53
|
this.handleSudoRequests(this.childProcess);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
async fullTest(configs: ResourceConfig[]): Promise<void> {
|
|
56
|
+
async fullTest(configs: ResourceConfig[], assertPlans?: (plans: PlanResponseData[]) => void): Promise<void> {
|
|
57
57
|
const initializeResult = await this.initialize();
|
|
58
58
|
|
|
59
59
|
const unsupportedConfigs = configs.filter((c) =>
|
|
@@ -75,6 +75,10 @@ export class PluginTester {
|
|
|
75
75
|
plans.push(await this.plan(config));
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
if (assertPlans) {
|
|
79
|
+
assertPlans(plans);
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
for (const plan of plans) {
|
|
79
83
|
await this.apply({
|
|
80
84
|
planId: plan.planId
|
|
@@ -97,25 +101,25 @@ ${JSON.stringify(unsuccessfulPlans, null, 2)}`
|
|
|
97
101
|
|
|
98
102
|
async uninstall(configs: ResourceConfig[]) {
|
|
99
103
|
for (const config of configs) {
|
|
100
|
-
const {
|
|
104
|
+
const { dependsOn, name, type, ...parameters } = config
|
|
101
105
|
|
|
102
106
|
await this.apply({
|
|
103
107
|
plan: {
|
|
104
108
|
operation: ResourceOperation.DESTROY,
|
|
105
|
-
resourceType: config.type,
|
|
106
109
|
parameters: Object.entries(parameters).map(([key, value]) => ({
|
|
107
110
|
name: key,
|
|
108
|
-
previousValue: value,
|
|
109
111
|
newValue: null,
|
|
110
112
|
operation: ParameterOperation.REMOVE,
|
|
113
|
+
previousValue: value,
|
|
111
114
|
})),
|
|
115
|
+
resourceType: type,
|
|
112
116
|
}
|
|
113
117
|
});
|
|
114
118
|
|
|
115
119
|
// Validate that the destroy was successful
|
|
116
120
|
const validationPlan = await this.plan(config);
|
|
117
121
|
if (validationPlan.operation !== ResourceOperation.CREATE) {
|
|
118
|
-
throw new Error(`Resource ${
|
|
122
|
+
throw new Error(`Resource ${type} was not successfully destroyed.
|
|
119
123
|
Validation plan shows:
|
|
120
124
|
${JSON.stringify(validationPlan, null, 2)}
|
|
121
125
|
Previous config:
|
|
@@ -152,6 +156,10 @@ ${JSON.stringify(config, null, 2)}`
|
|
|
152
156
|
data,
|
|
153
157
|
});
|
|
154
158
|
}
|
|
159
|
+
|
|
160
|
+
kill() {
|
|
161
|
+
this.childProcess.kill();
|
|
162
|
+
}
|
|
155
163
|
|
|
156
164
|
private handleSudoRequests(process: ChildProcess) {
|
|
157
165
|
// Listen for incoming sudo incoming sudo requests
|
|
@@ -190,8 +198,6 @@ type CodifySpawnOptions = {
|
|
|
190
198
|
*
|
|
191
199
|
* @param cmd Command to run. Ex: `rm -rf`
|
|
192
200
|
* @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
|
|
195
201
|
*
|
|
196
202
|
* @see promiseSpawn
|
|
197
203
|
* @see spawn
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { PluginTester } from '../src/
|
|
2
|
+
import { PluginTester } from '../src/index.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { ResourceOperation } from 'codify-schemas/src/types/index.js';
|
|
5
|
-
import { ParameterOperation } from 'codify-schemas';
|
|
6
5
|
|
|
7
6
|
describe('Plugin tester integration tests', () => {
|
|
8
7
|
it('Can instantiate a plugin', async () => {
|
|
@@ -13,7 +12,7 @@ describe('Plugin tester integration tests', () => {
|
|
|
13
12
|
expect(plugin.childProcess.stderr).to.not.be.undefined;
|
|
14
13
|
expect(plugin.childProcess.channel).to.not.be.undefined;
|
|
15
14
|
|
|
16
|
-
await plugin.initialize(
|
|
15
|
+
await plugin.initialize();
|
|
17
16
|
})
|
|
18
17
|
|
|
19
18
|
it('Can validate a config', async () => {
|
|
@@ -110,6 +109,35 @@ describe('Plugin tester integration tests', () => {
|
|
|
110
109
|
}]);
|
|
111
110
|
})
|
|
112
111
|
|
|
112
|
+
it('Full test supports plan assertions to ensure the generated plan is correct', async () => {
|
|
113
|
+
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
114
|
+
|
|
115
|
+
// No expect needed here. This passes if it doesn't throw.
|
|
116
|
+
await plugin.fullTest([{
|
|
117
|
+
type: 'test',
|
|
118
|
+
propA: 'a',
|
|
119
|
+
propB: 10,
|
|
120
|
+
propC: 'c',
|
|
121
|
+
}, {
|
|
122
|
+
type: 'test',
|
|
123
|
+
propA: 'a',
|
|
124
|
+
propB: 10,
|
|
125
|
+
propC: 'c',
|
|
126
|
+
}], (plans) => {
|
|
127
|
+
expect(plans[0]).toMatchObject({
|
|
128
|
+
planId: expect.any(String),
|
|
129
|
+
operation: ResourceOperation.NOOP,
|
|
130
|
+
resourceType: 'test',
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(plans[1]).toMatchObject({
|
|
134
|
+
planId: expect.any(String),
|
|
135
|
+
operation: ResourceOperation.NOOP,
|
|
136
|
+
resourceType: 'test',
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
|
|
113
141
|
it('Has helpers that can uninstall a resource', async () => {
|
|
114
142
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
115
143
|
|