|
| 1 | +/* |
| 2 | + * Copyright (c) 2020, salesforce.com, inc. |
| 3 | + * All rights reserved. |
| 4 | + * Licensed under the BSD 3-Clause license. |
| 5 | + * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause |
| 6 | + */ |
| 7 | + |
| 8 | +import { expect } from 'chai'; |
| 9 | +import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup'; |
| 10 | +import { stubSfCommandUx } from '@salesforce/sf-plugins-core'; |
| 11 | +import DeployMetadata from '../../../src/commands/project/deploy/start'; |
| 12 | + |
| 13 | +describe('project deploy start', () => { |
| 14 | + const $$ = new TestContext(); |
| 15 | + const testOrg = new MockTestOrgData(); |
| 16 | + testOrg.isScratchOrg = true; |
| 17 | + let warnStub: sinon.SinonStub; |
| 18 | + |
| 19 | + beforeEach(async () => { |
| 20 | + await $$.stubAuths(testOrg); |
| 21 | + await $$.stubConfig({ 'target-org': testOrg.username }); |
| 22 | + warnStub = stubSfCommandUx($$.SANDBOX).warn; |
| 23 | + }); |
| 24 | + |
| 25 | + afterEach(() => { |
| 26 | + $$.restore(); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should emit warning when PPDS=true', async () => { |
| 30 | + $$.setConfigStubContents('SfProjectJson', { |
| 31 | + contents: { |
| 32 | + packageDirectories: [{ path: 'force-app', default: true }], |
| 33 | + pushPackageDirectoriesSequentially: true, |
| 34 | + }, |
| 35 | + }); |
| 36 | + try { |
| 37 | + await DeployMetadata.run([]); |
| 38 | + } catch (e) { |
| 39 | + expect(warnStub.firstCall.args[0]).to.contain('pushPackageDirectoriesSequentially'); |
| 40 | + expect(warnStub.called).to.be.true; |
| 41 | + // do nothing, only need to assert that it warns correctly, avoid too much UT setup |
| 42 | + } |
| 43 | + }); |
| 44 | + |
| 45 | + it('should not emit warning when PPDS=true and flags', async () => { |
| 46 | + $$.setConfigStubContents('SfProjectJson', { |
| 47 | + contents: { |
| 48 | + packageDirectories: [{ path: 'force-app', default: true }], |
| 49 | + pushPackageDirectoriesSequentially: true, |
| 50 | + }, |
| 51 | + }); |
| 52 | + try { |
| 53 | + await DeployMetadata.run(['--source-dir', 'test']); |
| 54 | + } catch (e) { |
| 55 | + expect(warnStub.called).to.be.false; |
| 56 | + // do nothing, only need to assert that it warns correctly, avoid too much UT setup |
| 57 | + } |
| 58 | + }); |
| 59 | + |
| 60 | + it('should not emit warning when PPDS=false and a flag', async () => { |
| 61 | + $$.setConfigStubContents('SfProjectJson', { |
| 62 | + contents: { |
| 63 | + packageDirectories: [{ path: 'force-app', default: true }], |
| 64 | + pushPackageDirectoriesSequentially: false, |
| 65 | + }, |
| 66 | + }); |
| 67 | + try { |
| 68 | + await DeployMetadata.run(['--source-dir', 'test']); |
| 69 | + } catch (e) { |
| 70 | + expect(warnStub.called).to.be.false; |
| 71 | + // do nothing, only need to assert that it warns correctly, avoid too much UT setup |
| 72 | + } |
| 73 | + }); |
| 74 | +}); |
0 commit comments