-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate(W-14169233): spaces: Upgrade drains:set (#2851)
- Loading branch information
1 parent
89201a4
commit ed67ab2
Showing
6 changed files
with
54 additions
and
71 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,29 @@ | ||
import color from '@heroku-cli/color' | ||
import {Command, flags} from '@heroku-cli/command' | ||
import {Args, ux} from '@oclif/core' | ||
import * as Heroku from '@heroku-cli/schema' | ||
|
||
export default class Set extends Command { | ||
static topic = 'drains' | ||
static hidden = true | ||
static description = 'replaces the log drain for a space' | ||
static flags = { | ||
space: flags.string({char: 's', description: 'space for which to set log drain', required: true}), | ||
} | ||
|
||
static args = { | ||
url: Args.string({required: true}), | ||
} | ||
|
||
public async run(): Promise<void> { | ||
const {flags, args} = await this.parse(Set) | ||
const {url} = args | ||
const {space} = flags | ||
const {body: drain} = await this.heroku.put<Heroku.LogDrain>(`/spaces/${space}/log-drain`, { | ||
body: {url}, | ||
headers: {Accept: 'application/vnd.heroku+json; version=3.dogwood'}, | ||
}) | ||
ux.log(`Successfully set drain ${color.cyan(drain.url)} for ${color.cyan.bold(space)}.`) | ||
ux.warn('It may take a few moments for the changes to take effect.') | ||
} | ||
} |
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,25 @@ | ||
import {expect} from '@oclif/test' | ||
import * as nock from 'nock' | ||
import {stdout} from 'stdout-stderr' | ||
import runCommand from '../../../helpers/runCommand' | ||
import Cmd from '../../../../src/commands/drains/set' | ||
|
||
describe('drains:set', function () { | ||
it('shows the log drain', async function () { | ||
const api = nock('https://api.heroku.com:443') | ||
.put('/spaces/my-space/log-drain', { | ||
url: 'https://example.com', | ||
}) | ||
.reply(200, { | ||
addon: null, | ||
created_at: '2016-03-23T18:31:50Z', | ||
id: '047f80cc-0470-4564-b0cb-e9ad7605314a', | ||
token: 'd.a55ecbe1-5513-4d19-91e4-58a08b419d19', | ||
updated_at: '2016-03-23T18:31:50Z', | ||
url: 'https://example.com', | ||
}) | ||
await runCommand(Cmd, ['https://example.com', '--space', 'my-space']) | ||
expect(stdout.output).to.equal('Successfully set drain https://example.com for my-space.\n') | ||
api.done() | ||
}) | ||
}) |
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
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
31 changes: 0 additions & 31 deletions
31
packages/spaces/test/unit/commands/drains/set.unit.test.js
This file was deleted.
Oops, something went wrong.