Skip to content

Commit

Permalink
additional changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Jul 24, 2023
1 parent a7092d7 commit d5f2b4a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/commands/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default class Diff extends Command {
firstDocument = await load(firstDocumentPath);

if (firstDocument.isAsyncAPI3()) {
this.error('Diff command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/diff/issues/154');
this.error('Diff command does not support AsyncAPI v3 yet which was your first document, please checkout https://github.com/asyncapi/diff/issues/154');
}

enableWatch(watchMode, {
Expand All @@ -112,6 +112,11 @@ export default class Diff extends Command {

try {
secondDocument = await load(secondDocumentPath);

if (secondDocument.isAsyncAPI3()) {
this.error('Diff command does not support AsyncAPI v3 yet which was your second document, please checkout https://github.com/asyncapi/diff/issues/154');
}

enableWatch(watchMode, {
spec: secondDocument,
handler: this,
Expand Down
16 changes: 13 additions & 3 deletions test/commands/diff.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { test } from '@oclif/test';

const asyncapiv3 = './test/specification-v3.yml';
const asyncapiv2 = './test/specification.yml';
const noChangesJson = '"{\\n \\"changes\\": []\\n}\\n"';
const breakingChangesJson = '"[\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/protocol\\",\\n \\"before\\": \\"mqtt\\",\\n \\"after\\": \\"http\\",\\n \\"type\\": \\"breaking\\"\\n },\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/url\\",\\n \\"before\\": \\"mqtt://test.mosquitto.org\\",\\n \\"after\\": \\"http://test.mosquitto.org\\",\\n \\"type\\": \\"breaking\\"\\n }\\n]\\n"';
const nonBreakingChangesJson = '"[\\n {\\n \\"action\\": \\"add\\",\\n \\"path\\": \\"/channels/user~1signedup\\",\\n \\"after\\": {\\n \\"subscribe\\": {\\n \\"message\\": {\\n \\"payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-2>\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-3>\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-1>\\"\\n },\\n \\"x-parser-message-name\\": \\"UserSignedUp\\",\\n \\"x-parser-original-schema-format\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"schemaFormat\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"x-parser-original-payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-2>\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-3>\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-1>\\"\\n },\\n \\"x-parser-message-parsed\\": true\\n }\\n }\\n },\\n \\"type\\": \\"non-breaking\\"\\n },\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/info/title\\",\\n \\"before\\": \\"Streetlights API\\",\\n \\"after\\": \\"Streetlights API V2\\",\\n \\"type\\": \\"non-breaking\\"\\n },\\n {\\n \\"action\\": \\"add\\",\\n \\"path\\": \\"/components\\",\\n \\"after\\": {\\n \\"messages\\": {\\n \\"UserSignedUp\\": {\\n \\"payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-2>\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-3>\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-1>\\"\\n },\\n \\"x-parser-message-name\\": \\"UserSignedUp\\",\\n \\"x-parser-original-schema-format\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"schemaFormat\\": \\"application/vnd.aai.asyncapi;version=2.1.0\\",\\n \\"x-parser-original-payload\\": {\\n \\"type\\": \\"object\\",\\n \\"properties\\": {\\n \\"displayName\\": {\\n \\"type\\": \\"string\\",\\n \\"description\\": \\"Name of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-2>\\"\\n },\\n \\"email\\": {\\n \\"type\\": \\"string\\",\\n \\"format\\": \\"email\\",\\n \\"description\\": \\"Email of the user\\",\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-3>\\"\\n }\\n },\\n \\"x-parser-schema-id\\": \\"<anonymous-schema-1>\\"\\n },\\n \\"x-parser-message-parsed\\": true\\n }\\n }\\n },\\n \\"type\\": \\"non-breaking\\"\\n }\\n]\\n"';
Expand All @@ -21,9 +22,18 @@ describe('diff', () => {
test
.stderr()
.stdout()
.command(['diff', asyncapiv3, asyncapiv3])
.it('give error', (ctx, done) => {
expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/diff/issues/154\n');
.command(['diff', asyncapiv3, asyncapiv2])
.it('give error when first document', (ctx, done) => {
expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet which was your first document, please checkout https://github.com/asyncapi/diff/issues/154\n');
expect(ctx.stdout).toEqual('');
done();
});
test
.stderr()
.stdout()
.command(['diff', asyncapiv2, asyncapiv3])
.it('give error when second document', (ctx, done) => {
expect(ctx.stderr).toEqual('Error: Diff command does not support AsyncAPI v3 yet which was your second document, please checkout https://github.com/asyncapi/diff/issues/154\n');
expect(ctx.stdout).toEqual('');
done();
});
Expand Down
2 changes: 0 additions & 2 deletions test/specification-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,3 @@ components:
parameters:
streetlightId:
description: The ID of the streetlight.
schema:
type: string

0 comments on commit d5f2b4a

Please sign in to comment.