Skip to content

Commit

Permalink
feat: set QA apihost (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
vegeris authored Jun 17, 2024
2 parents 20f026b + 753a4de commit 91523a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 11 additions & 4 deletions packages/cli-test/src/cli/cli-process.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,25 @@ describe('SlackCLIProcess class', () => {

describe('CLI flag handling', () => {
describe('global options', () => {
it('should map qa or dev options to --slackdev', async () => {
let cmd = new SlackCLIProcess('help', { qa: true });
it('should map dev option to --slackdev', async () => {
let cmd = new SlackCLIProcess('help', { dev: true });
await cmd.execAsync();
sandbox.assert.calledWithMatch(spawnProcessSpy, '--slackdev');
spawnProcessSpy.resetHistory();
cmd = new SlackCLIProcess('help');
await cmd.execAsync();
sandbox.assert.neverCalledWithMatch(spawnProcessSpy, '--slackdev');
spawnProcessSpy.resetHistory();
cmd = new SlackCLIProcess('help', { dev: true });
});
it('should map qa option to QA host', async () => {
let cmd = new SlackCLIProcess('help', { qa: true });
await cmd.execAsync();
sandbox.assert.calledWithMatch(spawnProcessSpy, '--slackdev');
sandbox.assert.calledWithMatch(spawnProcessSpy, '--apihost qa.slack.com');
spawnProcessSpy.resetHistory();
cmd = new SlackCLIProcess('help');
await cmd.execAsync();
sandbox.assert.neverCalledWithMatch(spawnProcessSpy, '--apihost qa.slack.com');
spawnProcessSpy.resetHistory();
});
it('should default to passing --skip-update but allow overriding that', async () => {
let cmd = new SlackCLIProcess('help');
Expand Down
7 changes: 5 additions & 2 deletions packages/cli-test/src/cli/cli-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface SlackCLIGlobalOptions {
*/
dev?: boolean;
/**
* @description Whether the command should interact with dev.slack (`--slackdev`)
* @description Whether the command should interact with qa.slack (`--apihost qa.slack.com`)
*/
qa?: boolean;
/**
Expand Down Expand Up @@ -87,7 +87,10 @@ export class SlackCLIProcess {
let cmd = `${process.env.SLACK_CLI_PATH}`;
if (this.globalOptions) {
const opts = this.globalOptions;
if (opts.qa || opts.dev) {
if (opts.qa) {
cmd += ' --apihost qa.slack.com';
}
if (opts.dev) {
cmd += ' --slackdev';
}
if (opts.skipUpdate || opts.skipUpdate === undefined) {
Expand Down

0 comments on commit 91523a1

Please sign in to comment.