Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishalk91-4 committed Sep 28, 2024
1 parent b5e30f8 commit 8083655
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/core/errors/validation-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ export class ValidationError extends Error {
this.buildError(error.err);
}
if (error.type === 'invalid-file') {
this.message = `There is no file or context with the name "${error.filepath}". Please check the path and try again.`;
this.message = `There is no file or context with name "${error.filepath}".`;
}
if (error.type === 'no-spec-found') {
this.message = 'Unable to perform validation. Please specify which AsyncAPI file should be validated.';
this.message = 'Unable to perform validation. Specify what AsyncAPI file should be validated.\n\nThese are your options to specify in the CLI what AsyncAPI file should be used:\n- You can provide a path to the AsyncAPI file: asyncapi validate path/to/file/asyncapi.yml\n- You can also pass a saved context that points to your AsyncAPI file: asyncapi validate mycontext\n- In case you did not specify a context that you want to use, the CLI checks if there is a default context and uses it. To set default context run: asyncapi context use mycontext\n- In case you did not provide any reference to AsyncAPI file and there is no default context, the CLI detects if in your current working directory you have files like asyncapi.json, asyncapi.yaml, asyncapi.yml. Just rename your file accordingly.';
}
this.name = 'ValidationError';
}

private buildError(err: any) {
const errorsInfo: Array<string> = [];

Expand Down
6 changes: 3 additions & 3 deletions test/integration/optimize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('optimize', () => {
.stdout()
.command(['optimize', optimizedFilePath])
.it('works when file path is passed', (ctx, done) => {
expect(ctx.stdout).to.contain(`No optimization has been applied since ${optimizedFilePath} looks optimized!`);
expect(ctx.stdout).to.contain(`🎉 Great news! Your file at ${optimizedFilePath} is already optimized.`);
expect(ctx.stderr).to.equal('');
done();
});
Expand All @@ -54,7 +54,7 @@ describe('optimize', () => {
.stdout()
.command(['optimize', 'http://localhost:8080/dummySpecWithoutSecurity.yml'])
.it('works when url is passed', (ctx, done) => {
expect(ctx.stdout).to.contain('No optimization has been applied since http://localhost:8080/dummySpecWithoutSecurity.yml looks optimized!');
expect(ctx.stdout).to.contain('🎉 Great news! Your file at http://localhost:8080/dummySpecWithoutSecurity.yml is already optimized.');
expect(ctx.stderr).to.equal('');
done();
});
Expand All @@ -75,7 +75,7 @@ describe('optimize', () => {
.stdout()
.command(['optimize'])
.it('converts from current context', (ctx, done) => {
expect(ctx.stdout).to.contain(`No optimization has been applied since ${path.resolve(__dirname, '../fixtures/specification.yml')} looks optimized!`);
expect(ctx.stdout).to.contain(`🎉 Great news! Your file at ${path.resolve(__dirname, '../fixtures/specification.yml')} is already optimized.`);
expect(ctx.stderr).to.equal('');
done();
});
Expand Down

0 comments on commit 8083655

Please sign in to comment.