Skip to content

Commit

Permalink
chore: change file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal committed Aug 2, 2023
1 parent 77129cc commit 3121489
Show file tree
Hide file tree
Showing 44 changed files with 262 additions and 254 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
!assets/examples/default-example.yaml
!assets/examples/tutorial.yml
node_modules
/test/functionality/commands/generate/models/
/test/integration/generate/models/
asyncapi.json
asyncapi.yml
test/minimaltemplate/__transpiled
test/fixtures/minimaltemplate/__transpiled
.vscode


Expand Down
4 changes: 2 additions & 2 deletions assets/create-glee-app/templates/default/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ asyncapi/cli [COMMAND HERE]
# Example that you can run inside the cli directory after cloning this repository. First, you specify the mount in the location of your AsyncAPI specification file and then you mount it in the directory where the generation result should be saved.
docker run --rm -it \
--user=root \
-v ${PWD}/test/functionality/fixtures/asyncapi_v1.yml:/app/asyncapi.yml \
-v ${PWD}/test/integration/fixtures/asyncapi_v1.yml:/app/asyncapi.yml \
-v ${PWD}/output:/app/output \
asyncapi/cli generate fromTemplate -o /app/output /app/asyncapi.yml @asyncapi/html-template --force-write
```
Expand Down
18 changes: 12 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"ws": "^8.2.3"
},
"devDependencies": {
"@asyncapi/minimaltemplate": "./test/minimaltemplate",
"@asyncapi/minimaltemplate": "./test/fixtures/minimaltemplate",
"@babel/core": "^7.19.3",
"@jest/types": "^29.1.0",
"@oclif/test": "^2",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"description": "Custom version to be used"
},
"mode": {
"description": "developement or production"
"description": "development or production"
}
}
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
102 changes: 0 additions & 102 deletions test/functionality/commands/bundle/bundle.test.ts

This file was deleted.

6 changes: 3 additions & 3 deletions test/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import SpecificationFile from '../../src/models/SpecificationFile';
import http from 'http';

const ASYNCAPI_FILE_PATH = path.resolve(process.cwd(), 'specification.yaml');
const SERVER_DIRECTORY= path.join(__dirname, '../functionality/dummyspec');
const SERVER_DIRECTORY= path.join(__dirname, '../fixtures/dummyspec');
export const PROJECT_DIRECTORY_PATH = path.join(process.cwd(), 'test-project');

let server: http.Server;

export default class ContextTestingHelper {
private _context: IContextFile;
constructor() {
const homeSpecFile = new SpecificationFile(path.resolve(__dirname, '../functionality/specification.yml'));
const homeSpecFile = new SpecificationFile(path.resolve(__dirname, '../fixtures/specification.yml'));

const codeSpecFile = new SpecificationFile(path.resolve(__dirname, '../functionality/specification.yml'));
const codeSpecFile = new SpecificationFile(path.resolve(__dirname, '../fixtures/specification.yml'));
this._context = {
current: 'home',
store: {
Expand Down
102 changes: 102 additions & 0 deletions test/integration/bundle/bundle.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import { test } from '@oclif/test';
import fs from 'fs';
import path from 'path';
import { fileCleanup } from '../../helpers';

const spec = fs.readFileSync('./test/integration/bundle/final-asyncapi.yaml', {encoding: 'utf-8'});
const asyncapiv3 = './test/fixtures/specification-v3.yml';

function validateGeneratedSpec(filePath, spec) {
const generatedSPec = fs.readFileSync(path.resolve(filePath), { encoding: 'utf-8' });
return generatedSPec === spec;
}

describe('bundle', () => {
describe('should handle AsyncAPI v3 document correctly', () => {
test
.stderr()
.stdout()
.command([
'bundle',
asyncapiv3,
'--output=./test/integration/bundle/final.yaml'])
.it('give error', (ctx, done) => {
expect(ctx.stderr).toEqual('Error: One of the files you tried to bundle is AsyncAPI v3 format, the bundle command does not support it yet, please checkout https:/asyncapi/bundler/issues/133\n');
expect(ctx.stdout).toEqual('');
done();
});
});

test
.stdout()
.command([
'bundle', './test/integration/bundle/first-asyncapi.yaml',
'--output=./test/integration/bundle/final.yaml',
])
.it('should successfully bundle specification', (ctx, done) => {
expect(ctx.stdout).toContain(
'Check out your shiny new bundled files at ./test/integration/bundle/final.yaml'
);
fileCleanup('./test/integration/bundle/final.yaml');
done();
});

test
.stdout()
.command([
'bundle', './test/integration/bundle/first-asyncapi.yaml',
'--output=./test/integration/bundle/final.json'
])
.it('should successfully bundle specification into json file', (ctx, done) => {
expect(ctx.stdout).toContain(
'Check out your shiny new bundled files at ./test/integration/bundle/final.json'
);
fileCleanup('./test/integration/bundle/final.json');
done();
});

test
.stderr()
.command([
'bundle', './test/integration/bundle/asyncapi.yml'
])
.it('should throw error message if the file path is wrong', (ctx, done) => {
expect(ctx.stderr).toContain('error loading AsyncAPI document from file: ./test/integration/bundle/asyncapi.yml file does not exist.\n');
done();
});

test
.stdout()
.command([
'bundle', './test/integration/bundle/first-asyncapi.yaml', '--reference-into-components', '--output=./test/integration/bundle/final.yaml'
])
.it('should be able to refence messages into components', (ctx, done) => {
expect(ctx.stdout).toContain('Check out your shiny new bundled files at ./test/integration/bundle/final.yaml\n');
fileCleanup('./test/integration/bundle/final.yaml');
done();
});

test
.stdout()
.command([
'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--reference-into-components', '--output=test/integration/bundle/final.yaml'
])
.it('should be able to bundle multiple specs along with custom reference', (ctx, done) => {
expect(ctx.stdout).toContain('Check out your shiny new bundled files at test/integration/bundle/final.yaml\n');
expect(validateGeneratedSpec('test/integration/bundle/final.yaml', spec));
fileCleanup('./test/integration/bundle/final.yaml');
done();
});

test
.stdout()
.command([
'bundle', './test/integration/bundle/first-asyncapi.yaml', './test/integration/bundle/feature.yaml', '--reference-into-components', '--output=test/integration/bundle/final.yaml', '--base=./test/integration/bundle/first-asyncapi.yaml'
])
.it('should be able to bundle correctly with overwriting base file', (ctx, done) => {
expect(ctx.stdout).toContain('Check out your shiny new bundled files at test/integration/bundle/final.yaml\n');
expect(validateGeneratedSpec('test/integration/bundle/final-asyncapi.yaml', spec));
fileCleanup('./test/integration/bundle/final.yaml');
done();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ channels:
user/loggedOut:
subcribe:
message:
$ref: 'test/functionality/commands/bundle/messages.yaml#/messages/UserLoggedOut'
$ref: 'test/integration/bundle/messages.yaml#/messages/UserLoggedOut'

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ channels:
user/signedup:
subscribe:
message:
$ref: "./test/functionality/commands/bundle/messages.yaml#/messages/UserSignedUp"
$ref: "./test/integration/bundle/messages.yaml#/messages/UserSignedUp"
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'path';
import { test } from '@oclif/test';

import TestHelper from '../../helpers';
import TestHelper from '../helpers';

const testHelper = new TestHelper();

Expand Down Expand Up @@ -33,7 +33,7 @@ describe('config', () => {
.command(['config:context:list'])
.it('should list contexts prints list if context file is present', (ctx, done) => {
expect(ctx.stdout).toEqual(
`home: ${path.resolve(__dirname, '../specification.yml')}\ncode: ${path.resolve(__dirname, '../specification.yml')}\n`
`home: ${path.resolve(__dirname, '../fixtures/specification.yml')}\ncode: ${path.resolve(__dirname, '../fixtures/specification.yml')}\n`
);
expect(ctx.stderr).toEqual('');
done();
Expand All @@ -44,7 +44,7 @@ describe('config', () => {
test
.stderr()
.stdout()
.command(['config:context:add', 'test', './test/functionality/specification.yml'])
.command(['config:context:add', 'test', './test/integration/specification.yml'])
.it('should add new context called "test"', (ctx, done) => {
expect(ctx.stdout).toEqual(
'Added context "test".\n\nYou can set it as your current context: asyncapi config context use test\nYou can use this context when needed by passing test as a parameter: asyncapi validate test\n'
Expand Down
Loading

0 comments on commit 3121489

Please sign in to comment.