-
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.
refactor(container-registry-v5): move container:rm to CLI & upgrade t…
…o oclif (#2656) * Convert container:rm to oclif * Convert rm test to test oclif version * Remove rm from container-v5 * Update test output check * Include docker variant header and expect it in test
- Loading branch information
Showing
5 changed files
with
92 additions
and
85 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import {Command, flags} from '@heroku-cli/command' | ||
import {ux} from '@oclif/core' | ||
import color from '@heroku-cli/color' | ||
|
||
export default class Rm extends Command { | ||
static topic = 'container' | ||
static description = 'remove the process type from your app' | ||
static usage = '$ heroku container:rm -a APP [-v] PROCESS_TYPE...' | ||
static example = ` | ||
${color.cmd('heroku container:rm web')} # Destroys the web container | ||
${color.cmd('heroku container:rm web worker')} # Destroys the web and worker containers` | ||
|
||
static strict = false | ||
|
||
static flags = { | ||
app: flags.app({required: true}), | ||
} | ||
|
||
async run() { | ||
const {argv, flags} = await this.parse(Rm) | ||
const {app} = flags | ||
|
||
if (argv.length === 0) { | ||
this.error(`Error: Requires one or more process types\n${Rm.example}`) | ||
} | ||
|
||
for (const process of argv as string[]) { | ||
ux.action.start(`Removing container ${process} for ${color.app(app)}`) | ||
await this.heroku.patch(`/apps/${app}/formation/${process}`, { | ||
headers: { | ||
Accept: 'application/vnd.heroku+json; version=3.docker-releases', | ||
}, | ||
body: {docker_image: null}, | ||
}) | ||
ux.action.stop() | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import {stdout, stderr} from 'stdout-stderr' | ||
import Cmd from '../../../src/commands/container/rm' | ||
import runCommand from '../../helpers/runCommand' | ||
import expectOutput from '../../helpers/utils/expectOutput' | ||
import * as nock from 'nock' | ||
import {expect} from 'chai' | ||
|
||
describe('container removal', () => { | ||
it('removes one container', async () => { | ||
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.docker-releases'}}) | ||
.patch('/apps/testapp/formation/web') | ||
.reply(200, {}) | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'testapp', | ||
'web', | ||
]) | ||
expectOutput(stdout.output, '') | ||
expectOutput(stderr.output, ` | ||
Removing container web for ⬢ testapp... | ||
Removing container web for ⬢ testapp... done | ||
`) | ||
}) | ||
it('removes two containers', async () => { | ||
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.docker-releases'}}) | ||
.patch('/apps/testapp/formation/web') | ||
.reply(200, {}) | ||
.patch('/apps/testapp/formation/worker') | ||
.reply(200, {}) | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'testapp', | ||
'web', | ||
'worker', | ||
]) | ||
expectOutput(stdout.output, '') | ||
expectOutput(stderr.output, ` | ||
Removing container web for ⬢ testapp... | ||
Removing container web for ⬢ testapp... done | ||
Removing container worker for ⬢ testapp... | ||
Removing container worker for ⬢ testapp... done | ||
`) | ||
}) | ||
|
||
it('requires a container to be specified', async () => { | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'testapp', | ||
]).catch((error: any) => { | ||
expect(error.message).to.contain('Requires one or more process types') | ||
}) | ||
expectOutput(stdout.output, '') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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
48 changes: 0 additions & 48 deletions
48
packages/container-registry-v5/test/unit/commands/rm.unit.test.js
This file was deleted.
Oops, something went wrong.