|
4 | 4 | * Licensed under the BSD 3-Clause license.
|
5 | 5 | * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
6 | 6 | */
|
7 |
| -import { test } from '@oclif/test'; |
| 7 | +import { expect, test } from '@oclif/test'; |
8 | 8 | import * as sinon from 'sinon';
|
| 9 | +import { LocalRun } from '@heroku/functions-core'; |
9 | 10 |
|
10 |
| -import * as library from '@heroku/functions-core'; |
11 |
| -import { Benny } from '@heroku/functions-core'; |
12 |
| - |
13 |
| -describe('function:start', () => { |
| 11 | +describe('run:function:start', () => { |
14 | 12 | let sandbox: sinon.SinonSandbox;
|
15 |
| - let bennyRunStub: sinon.SinonStub; |
16 |
| - let bennyBuildStub: sinon.SinonStub; |
| 13 | + let localRunExecStub: sinon.SinonStub; |
17 | 14 | beforeEach(() => {
|
18 | 15 | sandbox = sinon.createSandbox();
|
19 |
| - bennyRunStub = sandbox.stub(Benny.prototype, 'run'); |
20 |
| - bennyBuildStub = sandbox.stub(Benny.prototype, 'build'); |
21 |
| - bennyRunStub.returns(true); |
22 |
| - bennyBuildStub.returns(true); |
23 |
| - sandbox |
24 |
| - .stub(library, 'getProjectDescriptor') |
25 |
| - .returns(Promise.resolve({ com: { salesforce: { id: 'allthethingsfunction' } } })); |
| 16 | + localRunExecStub = sandbox.stub(LocalRun.prototype, 'exec'); |
| 17 | + localRunExecStub.resolves(); |
26 | 18 | });
|
27 | 19 |
|
28 | 20 | afterEach(() => {
|
29 | 21 | sandbox.restore();
|
30 | 22 | });
|
31 | 23 |
|
32 |
| - test.command(['run:function:start']).it('Should call the library methods', async () => { |
33 |
| - sinon.assert.calledOnce(bennyBuildStub); |
34 |
| - sinon.assert.calledOnce(bennyRunStub); |
| 24 | + test.command(['run:function:start']).it('Should call LocalRun.exec', async () => { |
| 25 | + sinon.assert.calledOnce(localRunExecStub); |
| 26 | + }); |
| 27 | + |
| 28 | + ['--builder', '--network', '--env'].forEach((deprecatedArg) => { |
| 29 | + describe(`with deprecated arg ${deprecatedArg}`, () => { |
| 30 | + test |
| 31 | + .stderr() |
| 32 | + .command(['run:function:start', deprecatedArg, 'some:val']) |
| 33 | + .it('will include a deprecation notice', (ctx) => { |
| 34 | + expect(ctx.stderr).to.contain(`${deprecatedArg} is deprecated`); |
| 35 | + }); |
| 36 | + }); |
| 37 | + }); |
| 38 | + |
| 39 | + ['--no-pull', '--no-run', '--no-build'].forEach((deprecatedArg) => { |
| 40 | + describe(`with deprecated flag ${deprecatedArg}`, () => { |
| 41 | + test |
| 42 | + .stderr() |
| 43 | + .command(['run:function:start', deprecatedArg]) |
| 44 | + .it('will include a deprecation notice', (ctx) => { |
| 45 | + expect(ctx.stderr).to.contain(`${deprecatedArg} is deprecated`); |
| 46 | + }); |
| 47 | + }); |
35 | 48 | });
|
36 | 49 | });
|
0 commit comments