From 4f0cbf35090a6074cac698cb15f8930c2d1edbb7 Mon Sep 17 00:00:00 2001 From: Pavel Bodiachevskii Date: Fri, 26 Jul 2024 13:26:33 +0400 Subject: [PATCH] test(definitions): Pulsar bindings new tests structure https://github.com/asyncapi/spec-json-schemas/issues/551 --- .../pulsar/0.1.0/channel/example.json | 15 ---- .../pulsar/0.1.0/channel/extended.json | 9 -- .../channel/only required properties.json | 4 - .../channel/without required properties.json | 13 --- .../0.1.0/channel/wrongly extended.json | 10 --- .../bindings/pulsar/0.1.0/server/example.json | 3 - .../pulsar/0.1.0/server/extended.json | 7 -- .../server/only required properties.json | 1 - .../server/without required properties.json | 1 - .../pulsar/0.1.0/server/wrongly extended.json | 8 -- .../pulsar/pulsar channel binding.test.mjs | 69 +++++++++++++++ .../pulsar/pulsar server binding.test.mjs | 47 +++++++++++ test/bindings/pulsar/pulsar.test.mjs | 84 ------------------- 13 files changed, 116 insertions(+), 155 deletions(-) delete mode 100644 test/bindings/pulsar/0.1.0/channel/example.json delete mode 100644 test/bindings/pulsar/0.1.0/channel/extended.json delete mode 100644 test/bindings/pulsar/0.1.0/channel/only required properties.json delete mode 100644 test/bindings/pulsar/0.1.0/channel/without required properties.json delete mode 100644 test/bindings/pulsar/0.1.0/channel/wrongly extended.json delete mode 100644 test/bindings/pulsar/0.1.0/server/example.json delete mode 100644 test/bindings/pulsar/0.1.0/server/extended.json delete mode 100644 test/bindings/pulsar/0.1.0/server/only required properties.json delete mode 100644 test/bindings/pulsar/0.1.0/server/without required properties.json delete mode 100644 test/bindings/pulsar/0.1.0/server/wrongly extended.json create mode 100644 test/bindings/pulsar/pulsar channel binding.test.mjs create mode 100644 test/bindings/pulsar/pulsar server binding.test.mjs delete mode 100644 test/bindings/pulsar/pulsar.test.mjs diff --git a/test/bindings/pulsar/0.1.0/channel/example.json b/test/bindings/pulsar/0.1.0/channel/example.json deleted file mode 100644 index 11186640..00000000 --- a/test/bindings/pulsar/0.1.0/channel/example.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "namespace": "staging", - "persistence": "persistent", - "compaction": 1000, - "geo-replication": [ - "us-east1", - "us-west1" - ], - "retention": { - "time": 7, - "size": 1000 - }, - "ttl": 360, - "deduplication": false -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/channel/extended.json b/test/bindings/pulsar/0.1.0/channel/extended.json deleted file mode 100644 index 0ffd0881..00000000 --- a/test/bindings/pulsar/0.1.0/channel/extended.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "namespace": "staging", - "persistence": "persistent", - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/channel/only required properties.json b/test/bindings/pulsar/0.1.0/channel/only required properties.json deleted file mode 100644 index 293b0c6d..00000000 --- a/test/bindings/pulsar/0.1.0/channel/only required properties.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "namespace": "staging", - "persistence": "persistent" -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/channel/without required properties.json b/test/bindings/pulsar/0.1.0/channel/without required properties.json deleted file mode 100644 index 4ef738d3..00000000 --- a/test/bindings/pulsar/0.1.0/channel/without required properties.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compaction": 1000, - "geo-replication": [ - "us-east1", - "us-west1" - ], - "retention": { - "time": 7, - "size": 1000 - }, - "ttl": 360, - "deduplication": false -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/channel/wrongly extended.json b/test/bindings/pulsar/0.1.0/channel/wrongly extended.json deleted file mode 100644 index e20fcdd1..00000000 --- a/test/bindings/pulsar/0.1.0/channel/wrongly extended.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "namespace": "staging", - "persistence": "persistent", - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/server/example.json b/test/bindings/pulsar/0.1.0/server/example.json deleted file mode 100644 index b741b501..00000000 --- a/test/bindings/pulsar/0.1.0/server/example.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "tenant": "contoso" -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/server/extended.json b/test/bindings/pulsar/0.1.0/server/extended.json deleted file mode 100644 index 2da8cc79..00000000 --- a/test/bindings/pulsar/0.1.0/server/extended.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - } -} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/server/only required properties.json b/test/bindings/pulsar/0.1.0/server/only required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/pulsar/0.1.0/server/only required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/server/without required properties.json b/test/bindings/pulsar/0.1.0/server/without required properties.json deleted file mode 100644 index 9e26dfee..00000000 --- a/test/bindings/pulsar/0.1.0/server/without required properties.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/test/bindings/pulsar/0.1.0/server/wrongly extended.json b/test/bindings/pulsar/0.1.0/server/wrongly extended.json deleted file mode 100644 index e6738ad9..00000000 --- a/test/bindings/pulsar/0.1.0/server/wrongly extended.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "x-number": 0, - "x-string": "", - "x-object": { - "property": {} - }, - "ext-number": 1 -} \ No newline at end of file diff --git a/test/bindings/pulsar/pulsar channel binding.test.mjs b/test/bindings/pulsar/pulsar channel binding.test.mjs new file mode 100644 index 00000000..22cbb356 --- /dev/null +++ b/test/bindings/pulsar/pulsar channel binding.test.mjs @@ -0,0 +1,69 @@ +import { + JsonSchemaTestSuite, + JsonSchemaTestSuiteConfig, + JsonSchemaTestSuiteData +} from '@test/definitions/base-schema-test.mjs'; +import {describe} from 'vitest'; + +const config = new JsonSchemaTestSuiteConfig( + true, + [ + 'must have required property \'namespace\'', + 'must have required property \'persistence\'', + ], + true, + [] +); + +let data = { + "0.1.0": new JsonSchemaTestSuiteData( + require(`@bindings/pulsar/0.1.0/channel.json`), + [ + { + "namespace": "staging", + "persistence": "persistent", + "compaction": 1000, + "geo-replication": [ + "us-east1", + "us-west1" + ], + "retention": { + "time": 7, + "size": 1000 + }, + "ttl": 360, + "deduplication": false + } + ], + { + "namespace": "staging", + "persistence": "persistent" + }, + {}, + { + "namespace": "staging", + "persistence": "persistent", + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "namespace": "staging", + "persistence": "persistent", + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), +} + +describe.each([ + '0.1.0', +])('Pulsar channel binding v%s', (bindingVersion) => { + new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() +}) diff --git a/test/bindings/pulsar/pulsar server binding.test.mjs b/test/bindings/pulsar/pulsar server binding.test.mjs new file mode 100644 index 00000000..94083769 --- /dev/null +++ b/test/bindings/pulsar/pulsar server binding.test.mjs @@ -0,0 +1,47 @@ +import { + JsonSchemaTestSuite, + JsonSchemaTestSuiteConfig, + JsonSchemaTestSuiteData +} from '@test/definitions/base-schema-test.mjs'; +import {describe} from 'vitest'; + +const config = new JsonSchemaTestSuiteConfig( + false, + [], + true, + [] +); + +let data = { + "0.1.0": new JsonSchemaTestSuiteData( + require(`@bindings/pulsar/0.1.0/server.json`), + [ + { + "tenant": "contoso" + } + ], + {}, + {}, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + } + }, + { + "x-number": 0, + "x-string": "", + "x-object": { + "property": {} + }, + "ext-number": 1 + } + ), +} + +describe.each([ + '0.1.0', +])('Pulsar server binding v%s', (bindingVersion) => { + new JsonSchemaTestSuite(data[bindingVersion], config).testSuite() +}) diff --git a/test/bindings/pulsar/pulsar.test.mjs b/test/bindings/pulsar/pulsar.test.mjs deleted file mode 100644 index c2d4c5fa..00000000 --- a/test/bindings/pulsar/pulsar.test.mjs +++ /dev/null @@ -1,84 +0,0 @@ -import {it} from 'vitest'; -import TestHelper from '@test/test-helper.mjs'; -import path from 'path'; - -describe.each([ - '0.1.0', -])('Pulsar bindings v%s', async (bindingVersion) => { - - const channelSchema = await import(`@bindings/pulsar/${bindingVersion}/channel.json`); - const serverSchema = await import(`@bindings/pulsar/${bindingVersion}/server.json`); - - describe('channel', () => { - it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid( - channelSchema, - path.resolve(__dirname, `./${bindingVersion}/channel/example.json`), - )); - - it(TestHelper.cannotBeEmptyTestName, () => TestHelper.objectIsNotValid( - channelSchema, - {}, - [ - 'must have required property \'namespace\'', - 'must have required property \'persistence\'' - ] - )); - - it(TestHelper.isNotValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsNotValid( - channelSchema, - path.resolve(__dirname, `./${bindingVersion}/channel/without required properties.json`), - [ - 'must have required property \'namespace\'', - 'must have required property \'persistence\'' - ] - )); - - 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('server', () => { - it(TestHelper.exampleIsValidTestName, () => TestHelper.objectIsValid( - serverSchema, - path.resolve(__dirname, `./${bindingVersion}/server/example.json`), - )); - - it(TestHelper.canBeEmptyTestName, () => TestHelper.objectIsValid( - serverSchema, - {} - )); - - it(TestHelper.isValidWithoutRequiredPropertiesTestName, () => TestHelper.objectIsValid( - serverSchema, - path.resolve(__dirname, `./${bindingVersion}/server/without required properties.json`), - )); - - it(TestHelper.isValidWithOnlyRequiredPropertiesTestName, () => TestHelper.objectIsValid( - serverSchema, - path.resolve(__dirname, `./${bindingVersion}/server/only required properties.json`), - )); - - it(TestHelper.isValidWhenIsExtendedTestName, () => TestHelper.objectIsValid( - serverSchema, - path.resolve(__dirname, `./${bindingVersion}/server/extended.json`), - )); - - it(TestHelper.isNotValidWhenIsWronglyExtendedTestName, () => TestHelper.wronglyExtended( - serverSchema, - path.resolve(__dirname, `./${bindingVersion}/server/wrongly extended.json`), - )); - }) - -}) \ No newline at end of file