Skip to content

Commit e3ef4ae

Browse files
committed
Updated to use the latest API schemas
1 parent af40189 commit e3ef4ae

4 files changed

Lines changed: 55 additions & 27 deletions

File tree

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-plugin-test",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"ajv": "^8.12.0",
1717
"ajv-formats": "^3.0.1",
18-
"codify-schemas": "1.0.42"
18+
"codify-schemas": "1.0.45"
1919
},
2020
"devDependencies": {
2121
"@oclif/prettier-config": "^0.2.1",
@@ -28,7 +28,7 @@
2828
"tsx": "^4.7.3",
2929
"typescript": "^5",
3030
"vitest": "^1.4.0",
31-
"codify-plugin-lib": "1.0.73"
31+
"codify-plugin-lib": "1.0.76"
3232
},
3333
"engines": {
3434
"node": ">=18.0.0"

src/plugin-tester.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Ajv2020 from 'ajv/dist/2020.js';
1+
import Ajv from 'ajv';
22
import {
33
ApplyRequestData,
44
InitializeResponseData,
@@ -20,7 +20,7 @@ import path from 'node:path';
2020

2121
import { CodifyTestUtils } from './test-utils.js';
2222

23-
const ajv = new Ajv2020.default({
23+
const ajv = new Ajv.default({
2424
strict: true
2525
});
2626
const ipcMessageValidator = ajv.compile(IpcMessageSchema);
@@ -72,7 +72,11 @@ export class PluginTester {
7272

7373
const plans = [];
7474
for (const config of configs) {
75-
plans.push(await this.plan(config));
75+
plans.push(await this.plan({
76+
desired: config,
77+
isStateful: false,
78+
state: undefined,
79+
}));
7680
}
7781

7882
if (assertPlans) {
@@ -88,7 +92,11 @@ export class PluginTester {
8892
// Check that all applys were successful by re-planning
8993
const validationPlans = [];
9094
for (const config of configs) {
91-
validationPlans.push(await this.plan(config));
95+
validationPlans.push(await this.plan({
96+
desired: config,
97+
isStateful: false,
98+
state: undefined,
99+
}));
92100
}
93101

94102
const unsuccessfulPlans = validationPlans.filter((p) => p.operation !== ResourceOperation.NOOP);
@@ -117,7 +125,11 @@ ${JSON.stringify(unsuccessfulPlans, null, 2)}`
117125
});
118126

119127
// Validate that the destroy was successful
120-
const validationPlan = await this.plan(config);
128+
const validationPlan = await this.plan({
129+
desired: config,
130+
state: undefined,
131+
isStateful: false,
132+
});
121133
if (validationPlan.operation !== ResourceOperation.CREATE) {
122134
throw new Error(`Resource ${type} was not successfully destroyed.
123135
Validation plan shows:

src/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Ajv2020 from 'ajv/dist/2020.js';
1+
import Ajv from 'ajv';
22
import { IpcMessage, IpcMessageSchema, MessageStatus } from 'codify-schemas';
33
import { ChildProcess } from 'node:child_process';
44

5-
const ajv = new Ajv2020.default({
5+
const ajv = new Ajv.default({
66
strict: true
77
});
88
const ipcMessageValidator = ajv.compile(IpcMessageSchema);

test/plugin-tester.test.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ describe('Plugin tester integration tests', () => {
3636
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
3737

3838
const result = await plugin.plan({
39-
type: 'test',
40-
propA: 'a',
41-
propB: 10,
42-
propC: 'c',
39+
desired: {
40+
type: 'test',
41+
propA: 'a',
42+
propB: 10,
43+
propC: 'c',
44+
},
45+
state: undefined,
46+
isStateful: false,
4347
})
4448

4549
expect(result).toMatchObject({
@@ -53,10 +57,14 @@ describe('Plugin tester integration tests', () => {
5357
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
5458

5559
const result = await plugin.plan({
56-
type: 'test',
57-
propA: 'a',
58-
propB: 10,
59-
propC: 'c',
60+
desired: {
61+
type: 'test',
62+
propA: 'a',
63+
propB: 10,
64+
propC: 'c',
65+
},
66+
state: undefined,
67+
isStateful: false,
6068
})
6169

6270
expect(result).toMatchObject({
@@ -70,10 +78,14 @@ describe('Plugin tester integration tests', () => {
7078
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
7179

7280
const plan = await plugin.plan({
73-
type: 'test',
74-
propA: 'a',
75-
propB: 10,
76-
propC: 'c',
81+
desired: {
82+
type: 'test',
83+
propA: 'a',
84+
propB: 10,
85+
propC: 'c',
86+
},
87+
state: undefined,
88+
isStateful: false,
7789
})
7890

7991
// No expect needed here. This passes if it doesn't throw.
@@ -84,11 +96,15 @@ describe('Plugin tester integration tests', () => {
8496
const plugin = new PluginTester(path.join(__dirname, './test-plugin.ts'));
8597

8698
expect(async () => plugin.plan({
87-
type: 'test',
88-
propA: 'a',
89-
propB: 10,
90-
propC: 'c',
91-
propD: 'any'
99+
desired: {
100+
type: 'test',
101+
propA: 'a',
102+
propB: 10,
103+
propC: 'c',
104+
propD: 'any'
105+
},
106+
state: undefined,
107+
isStateful: false,
92108
})).rejects.toThrowError(new Error('Prop D is included'));
93109
})
94110

0 commit comments

Comments
 (0)