Skip to content

Commit

Permalink
test(definitions): use .each for googlepubsub tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Jun 14, 2024
1 parent ce4bd27 commit 4dfb78c
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 180 deletions.
1 change: 0 additions & 1 deletion test/bindings/bindings.suite.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {describe} from 'vitest';

describe('Bindings Test Suite', async () => {
await import('@test/bindings/googlepubsub/index.mjs');
await import('@test/bindings/http/index.mjs');
await import('@test/bindings/ibmmq/index.mjs');
await import('@test/bindings/jms/index.mjs');
Expand Down
1 change: 0 additions & 1 deletion test/bindings/googlepubsub/0.1.0/channel/empty.json

This file was deleted.

45 changes: 0 additions & 45 deletions test/bindings/googlepubsub/0.1.0/channel/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/googlepubsub/0.1.0/message/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/googlepubsub/0.1.0/message/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/googlepubsub/0.2.0/channel/empty.json

This file was deleted.

43 changes: 0 additions & 43 deletions test/bindings/googlepubsub/0.2.0/channel/index.mjs

This file was deleted.

1 change: 0 additions & 1 deletion test/bindings/googlepubsub/0.2.0/message/empty.json

This file was deleted.

37 changes: 0 additions & 37 deletions test/bindings/googlepubsub/0.2.0/message/index.mjs

This file was deleted.

100 changes: 100 additions & 0 deletions test/bindings/googlepubsub/googlepubsub.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import {it} from 'vitest';
import TestHelper from '@test/test-helper.mjs';
import path from 'path';

describe.each([
'0.1.0',
'0.2.0',
])('Google Pub/Sub bindings v%s', async (bindingVersion) => {

const channelSchema = await import(`@bindings/googlepubsub/${bindingVersion}/channel.json`);
const messageSchema = await import(`@bindings/googlepubsub/${bindingVersion}/message.json`);

describe('channel', () => {
it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/example.json`),
));

it(TestHelper.cannotBeEmptyTestName, () => {
const expectedValidationErrorMessages = bindingVersion === '0.1.0'
? [
'must have required property \'schemaSettings\'',
'must have required property \'topic\''
]
: [
'must have required property \'schemaSettings\'',
]

TestHelper.objectIsNotValid(
channelSchema,
{},
expectedValidationErrorMessages
)
});

it(TestHelper.isNotValidWithoutRequiredPropertiesTestName, () => {
const expectedValidationErrorMessages = bindingVersion === '0.1.0'
? [
'must have required property \'schemaSettings\'',
'must have required property \'topic\''
]
: [
'must have required property \'schemaSettings\'',
]

TestHelper.objectIsNotValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/without required properties.json`),
expectedValidationErrorMessages
)
});

it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/only required properties.json`),
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/extended.json`),
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
channelSchema,
path.resolve(__dirname, `./${bindingVersion}/channel/wrongly extended.json`),
));
})

describe('message', () => {
it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/example.json`),
));

it(TestHelper.canBeEmptyTestName, () => TestHelper.objectIsValid(
messageSchema,
{}
));

it(TestHelper.isValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/without required properties.json`),
));

it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/only required properties.json`),
));

it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/extended.json`),
));

it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended(
messageSchema,
path.resolve(__dirname, `./${bindingVersion}/message/wrongly extended.json`),
));
})
})
13 changes: 0 additions & 13 deletions test/bindings/googlepubsub/index.mjs

This file was deleted.

1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig({
'**/test/bindings/bindings.suite.mjs',
'**/test/bindings/amqp/amqp.test.mjs',
'**/test/bindings/anypointmq/anypointmq.test.mjs',
'**/test/bindings/googlepubsub/googlepubsub.test.mjs',
'**/test/definitions/3.0.0/definitions.suite.mjs',
],
reporters: ['verbose'] // https://vitest.dev/guide/reporters#custom-reporters
Expand Down

0 comments on commit 4dfb78c

Please sign in to comment.