|
| 1 | +/* |
| 2 | + * Copyright (c) 2022, 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 { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; |
| 9 | +import { expect } from 'chai'; |
| 10 | + |
| 11 | +describe('bundle create/delete', () => { |
| 12 | + let session: TestSession; |
| 13 | + let bundleName: string; |
| 14 | + before(async () => { |
| 15 | + session = await TestSession.create({ |
| 16 | + devhubAuthStrategy: 'AUTO', |
| 17 | + project: { name: 'bundleCreateDelete' }, |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + after(async () => { |
| 22 | + await session?.clean(); |
| 23 | + }); |
| 24 | + describe('create/delete - human results', () => { |
| 25 | + before(async () => { |
| 26 | + bundleName = `test-bundle-${Date.now()}`; |
| 27 | + }); |
| 28 | + it('should create a bundle - human readable results', () => { |
| 29 | + const command = `package:bundle:create --name ${bundleName} -v ${session.hubOrg.username}`; |
| 30 | + const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; |
| 31 | + expect(output).to.contain('Ids'); |
| 32 | + expect(output).to.match(/Bundle Id\s+?|1Fl/); |
| 33 | + }); |
| 34 | + it('should delete a bundle - human readable results', () => { |
| 35 | + const command = `package:bundle:delete -b ${bundleName} -v ${session.hubOrg.username} --no-prompt`; |
| 36 | + const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; |
| 37 | + expect(output).to.contain('Successfully deleted the package bundle'); |
| 38 | + }); |
| 39 | + }); |
| 40 | + describe('create/delete - json results', () => { |
| 41 | + before(async () => { |
| 42 | + bundleName = `test-bundle-${Date.now()}`; |
| 43 | + }); |
| 44 | + it('should create a bundle - json results', () => { |
| 45 | + const command = `package:bundle:create --name ${bundleName} -v ${session.hubOrg.username} --json`; |
| 46 | + const output = execCmd<{ Id: string }>(command, { ensureExitCode: 0 }).jsonOutput; |
| 47 | + expect(output?.status).to.equal(0); |
| 48 | + expect(output?.result).to.have.property('Id'); |
| 49 | + expect(output?.result?.Id).to.match(/1Fl.{12,15}/); |
| 50 | + }); |
| 51 | + it('should delete a bundle - json results', () => { |
| 52 | + const command = `package:bundle:delete -b ${bundleName} -v ${session.hubOrg.username} --json`; |
| 53 | + const output = execCmd<{ id: string; success: boolean; errors: [] }>(command, { ensureExitCode: 0 }).jsonOutput; |
| 54 | + expect(output?.result?.id).to.match(/1Fl.{12,15}/); |
| 55 | + expect(output?.result?.success).to.be.true; |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
0 commit comments