-
Notifications
You must be signed in to change notification settings - Fork 16
Chore/add tests #217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Chore/add tests #217
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
617535b
WIP: app create tests
Mortza81 6b3333a
chore: add tests for app create command
Mortza81 d4276bf
add: login command tests
Mortza81 f5b220a
fix typo
Mortza81 b9449de
chore: account use command tests
3057076
fix typo
75fa40a
chore: complete account use command tests
Mortza81 376d743
start deploy command tests
Mortza81 c193432
chore: add test for deploy command
a63bddf
chore: image deployment test
Mortza81 3b3f17c
WIP: create-archive tests
Mortza81 15257c7
chore: add some tests for create archive function
9bdf6fe
chore: complete createArchive tests
Mortza81 5008e88
chore: complete createArchive tests
Mortza81 46600d0
chore: change fixtures
Mortza81 a0cada7
chore: add gitignore in fixtures
Mortza81 7a70426
delete unnecessary files in fixtures
Mortza81 195f9c9
Merge branch 'master' into chore/add-tests
Mortza81 855eaf8
update: tests
Mortza81 df4807c
chore: refactor getAllFiles()
Mortza81 30e5f24
fix: return node param
Mortza81 b75a678
chore: remove unnecessary param in network type
Mortza81 d401d5b
chore: add ci.yaml
Mortza81 73c8d3a
Merge branch 'master' into chore/add-tests
Mortza81 a959c64
chore: remove region from tests
Mortza81 26cbb92
fix: workflow
Mortza81 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,201 @@ | ||
| import { runCommand } from '@oclif/test'; | ||
| import nock from 'nock'; | ||
| import { expect } from 'chai'; | ||
| import { networks } from '../fixtures/networks/fixture.ts'; | ||
|
|
||
| describe('app:create', function () { | ||
| const api = nock('https://api.liara.ir'); | ||
|
|
||
| beforeEach(() => { | ||
| api.get('/v1/networks').query({ teamID: '' }).reply(200, networks); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| api.done(); | ||
| nock.cleanAll(); | ||
| }); | ||
|
|
||
| it('creates an app with the specified flags', async () => { | ||
| api | ||
| .post('/v1/projects/', { | ||
| name: 'test-app', | ||
| planID: 'small-g2', | ||
| platform: 'laravel', | ||
| bundlePlanID: 'standard', | ||
| network: networks.networks[0]._id, | ||
| readOnlyRootFilesystem: true, | ||
| }) | ||
| .query({ teamID: '' }) | ||
| .reply(200); | ||
|
|
||
| const { stdout } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'small-g2', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| networks.networks[0].name, | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(stdout).to.equal(`App test-app created.\n`); | ||
| }); | ||
|
|
||
| it('throws an error if app name already exists', async () => { | ||
| api | ||
| .post('/v1/projects/', { | ||
| name: 'test-app', | ||
| planID: 'small-g2', | ||
| platform: 'laravel', | ||
| bundlePlanID: 'standard', | ||
| network: networks.networks[0]._id, | ||
| readOnlyRootFilesystem: true, | ||
| }) | ||
| .query({ teamID: '' }) | ||
| .reply(409, { | ||
| statusCode: 409, | ||
| error: 'Conflict', | ||
| message: 'Project exists.', | ||
| data: null, | ||
| }); | ||
|
|
||
| const { error } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'small-g2', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| networks.networks[0].name, | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(error?.message).to.equal( | ||
| 'The app already exists. Please use a unique name for your app.', | ||
| ); | ||
| }); | ||
|
|
||
| it('throws an error if the network is not found', async () => { | ||
| const { error } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'small-g2', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| 'not-found', | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(error?.message).to.equal('Network not-found not found.'); | ||
| }); | ||
|
|
||
| it('thorws an error if user select a feature plan that is not available for free plan', async () => { | ||
| const { error } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'free', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| networks.networks[0].name, | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(error?.message).to.equal( | ||
| `Only "free" feature bundle plan is available for free plan.`, | ||
| ); | ||
| }); | ||
|
|
||
| it('throws an error if the user does not have enough balance', async () => { | ||
| api | ||
| .post('/v1/projects/', { | ||
| name: 'test-app', | ||
| planID: 'small-g2', | ||
| platform: 'laravel', | ||
| bundlePlanID: 'standard', | ||
| network: networks.networks[0]._id, | ||
| readOnlyRootFilesystem: true, | ||
| }) | ||
| .query({ teamID: '' }) | ||
| .reply(402); | ||
|
|
||
| const { error } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'small-g2', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| networks.networks[0].name, | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(error?.message).to.equal( | ||
| 'Not enough balance. Please charge your account.', | ||
| ); | ||
| }); | ||
|
|
||
| it('throws proper error if the app creation fails with status code 500', async () => { | ||
| api | ||
| .post('/v1/projects/', { | ||
| name: 'test-app', | ||
| planID: 'small-g2', | ||
| platform: 'laravel', | ||
| bundlePlanID: 'standard', | ||
| network: networks.networks[0]._id, | ||
| readOnlyRootFilesystem: true, | ||
| }) | ||
| .query({ teamID: '' }) | ||
| .reply(500); | ||
|
|
||
| const { error } = await runCommand([ | ||
| 'app:create', | ||
| '--app', | ||
| 'test-app', | ||
| '--platform', | ||
| 'laravel', | ||
| '--plan', | ||
| 'small-g2', | ||
| '--feature-plan', | ||
| 'standard', | ||
| '--network', | ||
| networks.networks[0].name, | ||
| '--read-only', | ||
| 'true', | ||
| ]); | ||
|
|
||
| expect(error?.message).to.equal(`Error: Unable to Create App | ||
| Please try the following steps: | ||
| 1. Check your internet connection. | ||
| 2. Ensure you have enough balance. | ||
| 3. Try again later. | ||
| 4. If you still have problems, please contact support by submitting a ticket at https://console.liara.ir/tickets`); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.