codify-plugin-test 0.0.4 → 0.0.6
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 +0 -1
- package/dist/plugin-tester.js +1 -1
- package/dist/plugin-tester.js.map +1 -1
- package/dist/test-utils.d.ts +0 -1
- package/package.json +3 -3
- package/src/plugin-tester.ts +18 -6
- package/src/test-utils.ts +2 -2
- package/test/plugin-tester.test.ts +34 -18
- package/test/test-plugin.ts +9 -21
package/dist/plugin-tester.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
1
|
import { ApplyRequestData, InitializeResponseData, PlanRequestData, PlanResponseData, ResourceConfig, ValidateRequestData, ValidateResponseData } from 'codify-schemas';
|
|
3
2
|
import { ChildProcess } from 'node:child_process';
|
|
4
3
|
export declare class PluginTester {
|
package/dist/plugin-tester.js
CHANGED
|
@@ -28,7 +28,7 @@ export class PluginTester {
|
|
|
28
28
|
throw new Error(`The plugin does not support the following configs supplied:\n ${JSON.stringify(unsupportedConfigs, null, 2)}\n Initialize result: ${JSON.stringify(initializeResult)}`);
|
|
29
29
|
}
|
|
30
30
|
const validate = await this.validate({ configs });
|
|
31
|
-
const invalidConfigs = validate.
|
|
31
|
+
const invalidConfigs = validate.resourceValidations.filter((v) => !v.isValid);
|
|
32
32
|
if (invalidConfigs.length > 0) {
|
|
33
33
|
throw new Error(`The following configs did not validate:\n ${JSON.stringify(invalidConfigs, null, 2)}`);
|
|
34
34
|
}
|
|
@@ -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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1
|
{
|
|
2
2
|
"name": "codify-plugin-test",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"ajv": "^8.12.0",
|
|
17
17
|
"ajv-formats": "^3.0.1",
|
|
18
|
-
"codify-schemas": "1.0.
|
|
18
|
+
"codify-schemas": "1.0.45"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@oclif/prettier-config": "^0.2.1",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"tsx": "^4.7.3",
|
|
29
29
|
"typescript": "^5",
|
|
30
30
|
"vitest": "^1.4.0",
|
|
31
|
-
"codify-plugin-lib": "1.0.
|
|
31
|
+
"codify-plugin-lib": "1.0.76"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=18.0.0"
|
package/src/plugin-tester.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
2
|
import {
|
|
3
3
|
ApplyRequestData,
|
|
4
4
|
InitializeResponseData,
|
|
@@ -20,7 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
|
|
21
21
|
import { CodifyTestUtils } from './test-utils.js';
|
|
22
22
|
|
|
23
|
-
const ajv = new
|
|
23
|
+
const ajv = new Ajv.default({
|
|
24
24
|
strict: true
|
|
25
25
|
});
|
|
26
26
|
const ipcMessageValidator = ajv.compile(IpcMessageSchema);
|
|
@@ -65,14 +65,18 @@ export class PluginTester {
|
|
|
65
65
|
|
|
66
66
|
const validate = await this.validate({ configs });
|
|
67
67
|
|
|
68
|
-
const invalidConfigs = validate.
|
|
68
|
+
const invalidConfigs = validate.resourceValidations.filter((v) => !v.isValid)
|
|
69
69
|
if (invalidConfigs.length > 0) {
|
|
70
70
|
throw new Error(`The following configs did not validate:\n ${JSON.stringify(invalidConfigs, null, 2)}`)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const plans = [];
|
|
74
74
|
for (const config of configs) {
|
|
75
|
-
plans.push(await this.plan(
|
|
75
|
+
plans.push(await this.plan({
|
|
76
|
+
desired: config,
|
|
77
|
+
isStateful: false,
|
|
78
|
+
state: undefined,
|
|
79
|
+
}));
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
if (assertPlans) {
|
|
@@ -88,7 +92,11 @@ export class PluginTester {
|
|
|
88
92
|
// Check that all applys were successful by re-planning
|
|
89
93
|
const validationPlans = [];
|
|
90
94
|
for (const config of configs) {
|
|
91
|
-
validationPlans.push(await this.plan(
|
|
95
|
+
validationPlans.push(await this.plan({
|
|
96
|
+
desired: config,
|
|
97
|
+
isStateful: false,
|
|
98
|
+
state: undefined,
|
|
99
|
+
}));
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
const unsuccessfulPlans = validationPlans.filter((p) => p.operation !== ResourceOperation.NOOP);
|
|
@@ -117,7 +125,11 @@ ${JSON.stringify(unsuccessfulPlans, null, 2)}`
|
|
|
117
125
|
});
|
|
118
126
|
|
|
119
127
|
// Validate that the destroy was successful
|
|
120
|
-
const validationPlan = await this.plan(
|
|
128
|
+
const validationPlan = await this.plan({
|
|
129
|
+
desired: config,
|
|
130
|
+
state: undefined,
|
|
131
|
+
isStateful: false,
|
|
132
|
+
});
|
|
121
133
|
if (validationPlan.operation !== ResourceOperation.CREATE) {
|
|
122
134
|
throw new Error(`Resource ${type} was not successfully destroyed.
|
|
123
135
|
Validation plan shows:
|
package/src/test-utils.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
2
|
import { IpcMessage, IpcMessageSchema, MessageStatus } from 'codify-schemas';
|
|
3
3
|
import { ChildProcess } from 'node:child_process';
|
|
4
4
|
|
|
5
|
-
const ajv = new
|
|
5
|
+
const ajv = new Ajv.default({
|
|
6
6
|
strict: true
|
|
7
7
|
});
|
|
8
8
|
const ipcMessageValidator = ajv.compile(IpcMessageSchema);
|
|
@@ -27,7 +27,7 @@ describe('Plugin tester integration tests', () => {
|
|
|
27
27
|
}]
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
expect(result.
|
|
30
|
+
expect(result.resourceValidations).toMatchObject([{
|
|
31
31
|
isValid: true,
|
|
32
32
|
}])
|
|
33
33
|
})
|
|
@@ -36,10 +36,14 @@ describe('Plugin tester integration tests', () => {
|
|
|
36
36
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
37
37
|
|
|
38
38
|
const result = await plugin.plan({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
desired: {
|
|
40
|
+
type: 'test',
|
|
41
|
+
propA: 'a',
|
|
42
|
+
propB: 10,
|
|
43
|
+
propC: 'c',
|
|
44
|
+
},
|
|
45
|
+
state: undefined,
|
|
46
|
+
isStateful: false,
|
|
43
47
|
})
|
|
44
48
|
|
|
45
49
|
expect(result).toMatchObject({
|
|
@@ -53,10 +57,14 @@ describe('Plugin tester integration tests', () => {
|
|
|
53
57
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
54
58
|
|
|
55
59
|
const result = await plugin.plan({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
desired: {
|
|
61
|
+
type: 'test',
|
|
62
|
+
propA: 'a',
|
|
63
|
+
propB: 10,
|
|
64
|
+
propC: 'c',
|
|
65
|
+
},
|
|
66
|
+
state: undefined,
|
|
67
|
+
isStateful: false,
|
|
60
68
|
})
|
|
61
69
|
|
|
62
70
|
expect(result).toMatchObject({
|
|
@@ -70,10 +78,14 @@ describe('Plugin tester integration tests', () => {
|
|
|
70
78
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
71
79
|
|
|
72
80
|
const plan = await plugin.plan({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
desired: {
|
|
82
|
+
type: 'test',
|
|
83
|
+
propA: 'a',
|
|
84
|
+
propB: 10,
|
|
85
|
+
propC: 'c',
|
|
86
|
+
},
|
|
87
|
+
state: undefined,
|
|
88
|
+
isStateful: false,
|
|
77
89
|
})
|
|
78
90
|
|
|
79
91
|
// No expect needed here. This passes if it doesn't throw.
|
|
@@ -84,11 +96,15 @@ describe('Plugin tester integration tests', () => {
|
|
|
84
96
|
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
|
|
85
97
|
|
|
86
98
|
expect(async () => plugin.plan({
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
desired: {
|
|
100
|
+
type: 'test',
|
|
101
|
+
propA: 'a',
|
|
102
|
+
propB: 10,
|
|
103
|
+
propC: 'c',
|
|
104
|
+
propD: 'any'
|
|
105
|
+
},
|
|
106
|
+
state: undefined,
|
|
107
|
+
isStateful: false,
|
|
92
108
|
})).rejects.toThrowError(new Error('Prop D is included'));
|
|
93
109
|
})
|
|
94
110
|
|
package/test/test-plugin.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Plugin, Resource, runPlugin } from 'codify-plugin-lib';
|
|
2
2
|
import { StringIndexedObject } from 'codify-schemas';
|
|
3
3
|
|
|
4
|
-
export interface TestConfig extends StringIndexedObject{
|
|
4
|
+
export interface TestConfig extends StringIndexedObject {
|
|
5
5
|
propA: string;
|
|
6
6
|
propB: number;
|
|
7
7
|
propC: string;
|
|
@@ -14,12 +14,12 @@ export class TestResource extends Resource<TestConfig> {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
async applyCreate(
|
|
17
|
+
async applyCreate(): Promise<void> {}
|
|
18
18
|
|
|
19
|
-
async applyDestroy(
|
|
19
|
+
async applyDestroy(): Promise<void> {}
|
|
20
20
|
|
|
21
|
-
async refresh(
|
|
22
|
-
if (
|
|
21
|
+
async refresh(parameters: Partial<TestConfig>): Promise<Partial<TestConfig> | null> {
|
|
22
|
+
if (parameters.propD) {
|
|
23
23
|
throw new Error('Prop D is included');
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,12 +29,6 @@ export class TestResource extends Resource<TestConfig> {
|
|
|
29
29
|
propC: 'c',
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
async validateResource(config: unknown): Promise<ValidationResult> {
|
|
34
|
-
return {
|
|
35
|
-
isValid: true
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
export class TestUninstallResource extends Resource<TestConfig> {
|
|
@@ -44,19 +38,13 @@ export class TestUninstallResource extends Resource<TestConfig> {
|
|
|
44
38
|
});
|
|
45
39
|
}
|
|
46
40
|
|
|
47
|
-
async applyCreate(
|
|
41
|
+
async applyCreate(): Promise<void> {}
|
|
48
42
|
|
|
49
|
-
async applyDestroy(
|
|
43
|
+
async applyDestroy(): Promise<void> {}
|
|
50
44
|
|
|
51
|
-
async refresh(
|
|
45
|
+
async refresh(): Promise<Partial<TestConfig> | null> {
|
|
52
46
|
return null;
|
|
53
47
|
}
|
|
54
|
-
|
|
55
|
-
async validateResource(config: unknown): Promise<ValidationResult> {
|
|
56
|
-
return {
|
|
57
|
-
isValid: true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
48
|
}
|
|
61
49
|
|
|
62
50
|
function buildPlugin(): Plugin {
|