-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update dyno restart and stop with fir support (#3061)
* Add logic for new dyno restart interface * Add tests for new restart functionality * Add ps:stop changes * fix tests * Fix help text test for stop dyno * Fix ps:restart example
- Loading branch information
Showing
6 changed files
with
218 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,16 +1,73 @@ | ||
import {expect, test} from '@oclif/test' | ||
import {stderr} from 'stdout-stderr' | ||
import Cmd from '../../../../src/commands/ps/restart' | ||
import runCommand from '../../../helpers/runCommand' | ||
import * as nock from 'nock' | ||
import heredoc from 'tsheredoc' | ||
import expectOutput from '../../../helpers/utils/expectOutput' | ||
import {expect} from 'chai' | ||
import stripAnsi = require('strip-ansi') | ||
|
||
describe('ps:restart', function () { | ||
test | ||
.stdout() | ||
.stderr() | ||
.nock('https://api.heroku.com:443', api => api | ||
it('restarts all dynos', async function () { | ||
nock('https://api.heroku.com') | ||
.delete('/apps/myapp/dynos') | ||
.reply(200), | ||
) | ||
.command(['ps:restart', '-a', 'myapp']) | ||
.it('restarts all dynos', ({stdout, stderr}) => { | ||
expect(stdout).to.be.empty | ||
expect(stderr).to.contains('Restarting dynos on ⬢ myapp... done\n') | ||
}) | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Restarting all dynos on ⬢ myapp... | ||
Restarting all dynos on ⬢ myapp... done | ||
`)) | ||
}) | ||
|
||
it('restarts web dynos', async function () { | ||
nock('https://api.heroku.com') | ||
.delete('/apps/myapp/formations/web') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--type', | ||
'web', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Restarting all web dynos on ⬢ myapp... | ||
Restarting all web dynos on ⬢ myapp... done | ||
`)) | ||
}) | ||
|
||
it('restarts a specific dyno', async function () { | ||
nock('https://api.heroku.com') | ||
.delete('/apps/myapp/dynos/web.1') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--dyno', | ||
'web.1', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Restarting dyno web.1 on ⬢ myapp... | ||
Restarting dyno web.1 on ⬢ myapp... done | ||
`)) | ||
}) | ||
|
||
it('emits a warning when passing dyno as an arg', async function () { | ||
nock('https://api.heroku.com') | ||
.delete('/apps/myapp/dynos/web.1') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'web.1', | ||
]) | ||
expect(stripAnsi(stderr.output)).to.include('Warning: Passing DYNO as an arg is deprecated.') | ||
expect(stderr.output).to.include('Restarting dyno web.1 on ⬢ myapp... done') | ||
}) | ||
}) |
This file contains 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 |
---|---|---|
@@ -1,29 +1,67 @@ | ||
import {expect, test} from '@oclif/test' | ||
import {stderr} from 'stdout-stderr' | ||
import Cmd from '../../../../src/commands/ps/stop' | ||
import runCommand from '../../../helpers/runCommand' | ||
import * as nock from 'nock' | ||
import heredoc from 'tsheredoc' | ||
import expectOutput from '../../../helpers/utils/expectOutput' | ||
import {expect} from 'chai' | ||
import stripAnsi = require('strip-ansi') | ||
|
||
describe('ps:stop', function () { | ||
test | ||
.stdout() | ||
.stderr() | ||
.nock('https://api.heroku.com:443', api => api | ||
.post('/apps/myapp/dynos/web/actions/stop') | ||
.reply(200), | ||
) | ||
.command(['ps:stop', 'web', '-a', 'myapp']) | ||
.it('stops all web dynos', ({stdout, stderr}) => { | ||
expect(stdout).to.be.empty | ||
expect(stderr).to.contains('Stopping web dynos on ⬢ myapp... done\n') | ||
it('requires a dyno name or type', async function () { | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]).catch(error => { | ||
expect(error.message).to.include('Please specify a process type or dyno to stop.') | ||
}) | ||
}) | ||
|
||
test | ||
.stdout() | ||
.stderr() | ||
.nock('https://api.heroku.com:443', api => api | ||
.post('/apps/myapp/dynos/run.10/actions/stop') | ||
.reply(200), | ||
) | ||
.command(['ps:stop', 'run.10', '-a', 'myapp']) | ||
.it('stops run.10 dyno', ({stdout, stderr}) => { | ||
expect(stdout).to.be.empty | ||
expect(stderr).to.contains('Stopping run.10 dyno on ⬢ myapp... done\n') | ||
}) | ||
it('restarts web dynos', async function () { | ||
nock('https://api.heroku.com') | ||
.post('/apps/myapp/formations/web/actions/stop') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--type', | ||
'web', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Stopping all web dynos on ⬢ myapp... | ||
Stopping all web dynos on ⬢ myapp... done | ||
`)) | ||
}) | ||
|
||
it('restarts a specific dyno', async function () { | ||
nock('https://api.heroku.com') | ||
.post('/apps/myapp/dynos/web.1/actions/stop') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--dyno', | ||
'web.1', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Stopping dyno web.1 on ⬢ myapp... | ||
Stopping dyno web.1 on ⬢ myapp... done | ||
`)) | ||
}) | ||
|
||
it('emits a warning when passing dyno as an arg', async function () { | ||
nock('https://api.heroku.com') | ||
.post('/apps/myapp/dynos/web.1/actions/stop') | ||
.reply(202) | ||
|
||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'web.1', | ||
]) | ||
expect(stripAnsi(stderr.output)).to.include('Warning: Passing DYNO as an arg is deprecated.') | ||
expect(stderr.output).to.include('Stopping dyno web.1 on ⬢ myapp... done') | ||
}) | ||
}) |