codify-plugin-test 0.0.2 → 0.0.3
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 +28 -3
- package/dist/plugin-tester.js.map +1 -1
- package/package.json +1 -1
- package/src/plugin-tester.ts +44 -6
- package/test/plugin-tester.test.ts +25 -1
- package/test/test-plugin.ts +25 -0
package/dist/plugin-tester.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { ChildProcess } from 'node:child_process';
|
|
|
4
4
|
export declare class PluginTester {
|
|
5
5
|
childProcess: ChildProcess;
|
|
6
6
|
constructor(pluginPath: string);
|
|
7
|
-
|
|
7
|
+
fullTest(configs: ResourceConfig[]): Promise<void>;
|
|
8
|
+
uninstall(configs: ResourceConfig[]): Promise<void>;
|
|
8
9
|
initialize(): Promise<InitializeResponseData>;
|
|
9
10
|
validate(data: ValidateRequestData): Promise<ValidateResponseData>;
|
|
10
11
|
plan(data: PlanRequestData): Promise<PlanResponseData>;
|
package/dist/plugin-tester.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
2
|
-
import { IpcMessageSchema, MessageCmd, ResourceOperation, SpawnStatus, SudoRequestDataSchema } from 'codify-schemas';
|
|
2
|
+
import { IpcMessageSchema, MessageCmd, ParameterOperation, ResourceOperation, SpawnStatus, SudoRequestDataSchema } from 'codify-schemas';
|
|
3
3
|
import { fork, spawn } from 'node:child_process';
|
|
4
4
|
import { CodifyTestUtils } from './test-utils.js';
|
|
5
5
|
import path from 'node:path';
|
|
@@ -21,7 +21,7 @@ export class PluginTester {
|
|
|
21
21
|
});
|
|
22
22
|
this.handleSudoRequests(this.childProcess);
|
|
23
23
|
}
|
|
24
|
-
async
|
|
24
|
+
async fullTest(configs) {
|
|
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) {
|
|
@@ -48,7 +48,32 @@ export class PluginTester {
|
|
|
48
48
|
const unsuccessfulPlans = validationPlans.filter((p) => p.operation !== ResourceOperation.NOOP);
|
|
49
49
|
if (unsuccessfulPlans.length > 0) {
|
|
50
50
|
throw new Error(`The following applies were not successful. Re-running plan shows that the resources did not return no-op but instead returned:
|
|
51
|
-
|
|
51
|
+
${JSON.stringify(unsuccessfulPlans, null, 2)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async uninstall(configs) {
|
|
55
|
+
for (const config of configs) {
|
|
56
|
+
const { type, dependsOn, name, ...parameters } = config;
|
|
57
|
+
await this.apply({
|
|
58
|
+
plan: {
|
|
59
|
+
operation: ResourceOperation.DESTROY,
|
|
60
|
+
resourceType: config.type,
|
|
61
|
+
parameters: Object.entries(parameters).map(([key, value]) => ({
|
|
62
|
+
name: key,
|
|
63
|
+
previousValue: value,
|
|
64
|
+
newValue: null,
|
|
65
|
+
operation: ParameterOperation.REMOVE,
|
|
66
|
+
})),
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const validationPlan = await this.plan(config);
|
|
70
|
+
if (validationPlan.operation !== ResourceOperation.CREATE) {
|
|
71
|
+
throw new Error(`Resource ${config.type} was not successfully destroyed.
|
|
72
|
+
Validation plan shows:
|
|
73
|
+
${JSON.stringify(validationPlan, null, 2)}
|
|
74
|
+
Previous config:
|
|
75
|
+
${JSON.stringify(config, null, 2)}`);
|
|
76
|
+
}
|
|
52
77
|
}
|
|
53
78
|
}
|
|
54
79
|
async initialize() {
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"plugin-tester.js","sourceRoot":"","sources":["../src/pl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B,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAA;QAEF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE5B,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YAC5B,OAAO,CAAC;gBACN,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrB,MAAM,EAAE,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK;aAC7D,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/plugin-tester.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import Ajv2020 from 'ajv/dist/2020.js';
|
|
2
2
|
import {
|
|
3
|
-
ApplyRequestData,
|
|
3
|
+
ApplyRequestData,
|
|
4
|
+
InitializeResponseData,
|
|
5
|
+
IpcMessageSchema,
|
|
4
6
|
MessageCmd,
|
|
7
|
+
ParameterOperation,
|
|
5
8
|
PlanRequestData,
|
|
6
|
-
PlanResponseData,
|
|
9
|
+
PlanResponseData,
|
|
10
|
+
ResourceConfig,
|
|
11
|
+
ResourceOperation,
|
|
7
12
|
SpawnStatus,
|
|
8
|
-
SudoRequestData,
|
|
13
|
+
SudoRequestData,
|
|
14
|
+
SudoRequestDataSchema,
|
|
15
|
+
ValidateRequestData,
|
|
16
|
+
ValidateResponseData
|
|
9
17
|
} from 'codify-schemas';
|
|
10
|
-
import { ChildProcess,
|
|
18
|
+
import { ChildProcess, fork, spawn, SpawnOptions } from 'node:child_process';
|
|
11
19
|
|
|
12
20
|
import { CodifyTestUtils } from './test-utils.js';
|
|
13
21
|
import path from 'node:path';
|
|
@@ -45,7 +53,7 @@ export class PluginTester {
|
|
|
45
53
|
this.handleSudoRequests(this.childProcess);
|
|
46
54
|
}
|
|
47
55
|
|
|
48
|
-
async
|
|
56
|
+
async fullTest(configs: ResourceConfig[]): Promise<void> {
|
|
49
57
|
const initializeResult = await this.initialize();
|
|
50
58
|
|
|
51
59
|
const unsupportedConfigs = configs.filter((c) =>
|
|
@@ -82,11 +90,41 @@ export class PluginTester {
|
|
|
82
90
|
const unsuccessfulPlans = validationPlans.filter((p) => p.operation !== ResourceOperation.NOOP);
|
|
83
91
|
if (unsuccessfulPlans.length > 0) {
|
|
84
92
|
throw new Error(`The following applies were not successful. Re-running plan shows that the resources did not return no-op but instead returned:
|
|
85
|
-
|
|
93
|
+
${JSON.stringify(unsuccessfulPlans, null, 2)}`
|
|
86
94
|
)
|
|
87
95
|
}
|
|
88
96
|
}
|
|
89
97
|
|
|
98
|
+
async uninstall(configs: ResourceConfig[]) {
|
|
99
|
+
for (const config of configs) {
|
|
100
|
+
const { type, dependsOn, name, ...parameters } = config
|
|
101
|
+
|
|
102
|
+
await this.apply({
|
|
103
|
+
plan: {
|
|
104
|
+
operation: ResourceOperation.DESTROY,
|
|
105
|
+
resourceType: config.type,
|
|
106
|
+
parameters: Object.entries(parameters).map(([key, value]) => ({
|
|
107
|
+
name: key,
|
|
108
|
+
previousValue: value,
|
|
109
|
+
newValue: null,
|
|
110
|
+
operation: ParameterOperation.REMOVE,
|
|
111
|
+
})),
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Validate that the destroy was successful
|
|
116
|
+
const validationPlan = await this.plan(config);
|
|
117
|
+
if (validationPlan.operation !== ResourceOperation.CREATE) {
|
|
118
|
+
throw new Error(`Resource ${config.type} was not successfully destroyed.
|
|
119
|
+
Validation plan shows:
|
|
120
|
+
${JSON.stringify(validationPlan, null, 2)}
|
|
121
|
+
Previous config:
|
|
122
|
+
${JSON.stringify(config, null, 2)}`
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
90
128
|
async initialize(): Promise<InitializeResponseData> {
|
|
91
129
|
return CodifyTestUtils.sendMessageAndAwaitResponse(this.childProcess, {
|
|
92
130
|
cmd: 'initialize',
|
|
@@ -97,7 +97,7 @@ describe('Plugin tester integration tests', () => {
|
|
|
97
97
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
98
98
|
|
|
99
99
|
// No expect needed here. This passes if it doesn't throw.
|
|
100
|
-
await plugin.
|
|
100
|
+
await plugin.fullTest([{
|
|
101
101
|
type: 'test',
|
|
102
102
|
propA: 'a',
|
|
103
103
|
propB: 10,
|
|
@@ -109,4 +109,28 @@ describe('Plugin tester integration tests', () => {
|
|
|
109
109
|
propC: 'c',
|
|
110
110
|
}]);
|
|
111
111
|
})
|
|
112
|
+
|
|
113
|
+
it('Has helpers that can uninstall a resource', async () => {
|
|
114
|
+
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
115
|
+
|
|
116
|
+
// No expect needed here. This passes if it doesn't throw.
|
|
117
|
+
await plugin.uninstall([{
|
|
118
|
+
type: 'test-uninstall',
|
|
119
|
+
propA: 'a',
|
|
120
|
+
propB: 10,
|
|
121
|
+
propC: 'c',
|
|
122
|
+
}]);
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('Has helpers that can uninstall a resource (errors out when unsuccessful)', async () => {
|
|
126
|
+
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
127
|
+
|
|
128
|
+
// No expect needed here. This passes if it doesn't throw.
|
|
129
|
+
expect(async () => plugin.uninstall([{
|
|
130
|
+
type: 'test',
|
|
131
|
+
propA: 'a',
|
|
132
|
+
propB: 10,
|
|
133
|
+
propC: 'c',
|
|
134
|
+
}])).rejects.toThrowError();
|
|
135
|
+
})
|
|
112
136
|
})
|
package/test/test-plugin.ts
CHANGED
|
@@ -37,12 +37,37 @@ export class TestResource extends Resource<TestConfig> {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
export class TestUninstallResource extends Resource<TestConfig> {
|
|
41
|
+
constructor() {
|
|
42
|
+
super({
|
|
43
|
+
type: 'test-uninstall'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async applyCreate(plan: Plan<TestConfig>): Promise<void> {}
|
|
48
|
+
|
|
49
|
+
async applyDestroy(plan: Plan<TestConfig>): Promise<void> {}
|
|
50
|
+
|
|
51
|
+
async refresh(keys: Map<string, unknown>): Promise<Partial<TestConfig> | null> {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async validateResource(config: unknown): Promise<ValidationResult> {
|
|
56
|
+
return {
|
|
57
|
+
isValid: true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
40
62
|
function buildPlugin(): Plugin {
|
|
41
63
|
const resourceMap = new Map();
|
|
42
64
|
|
|
43
65
|
const testResource = new TestResource();
|
|
44
66
|
resourceMap.set(testResource.typeId, testResource);
|
|
45
67
|
|
|
68
|
+
const testUninstallResource = new TestUninstallResource();
|
|
69
|
+
resourceMap.set(testUninstallResource.typeId, testUninstallResource);
|
|
70
|
+
|
|
46
71
|
return new Plugin('test', resourceMap);
|
|
47
72
|
}
|
|
48
73
|
|