generated from salesforcecli/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add package1:version:display command, NUT, pruned messages
- Loading branch information
1 parent
7389687
commit 23e0c8e
Showing
4 changed files
with
124 additions
and
19 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
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
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,87 @@ | ||
/* | ||
* Copyright (c) 2022, salesforce.com, inc. | ||
* All rights reserved. | ||
* Licensed under the BSD 3-Clause license. | ||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
|
||
import * as path from 'path'; | ||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { OrgConfigProperties } from '@salesforce/core'; | ||
import { expect } from 'chai'; | ||
import { Package1Display } from '../../../../../packaging'; | ||
|
||
describe('package1:version:display', () => { | ||
let session: TestSession; | ||
let usernameOrAlias: string; | ||
// TODO: na40 required as DevHub | ||
// hardcoded for now, eventually will be able to query from the org with package1:beta:version:list | ||
const packageVersionId = '04t46000001ZfaAAAS'; | ||
before(async () => { | ||
const executablePath = path.join(process.cwd(), 'bin', 'dev'); | ||
session = await TestSession.create({ | ||
setupCommands: [`${executablePath} config:get ${OrgConfigProperties.TARGET_DEV_HUB} --json`], | ||
project: { name: 'package1VersionDisplay' }, | ||
}); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
usernameOrAlias = (session.setup[0] as { result: [{ value: string }] }).result[0].value; | ||
|
||
if (!usernameOrAlias) throw Error('no default username set'); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
}); | ||
|
||
it('should list 1gp packages in dev hub - human readable results', function () { | ||
const command = `force:package1:beta:version:display -i ${packageVersionId} -u ${usernameOrAlias}`; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout as string; | ||
expect(output).to.match( | ||
/MetadataPackageVersionId\s+?MetadataPackageId\s+?Name\s+?Version\s+?ReleaseState\s+?BuildNumber/ | ||
); | ||
}); | ||
|
||
it('should list 1gp packages in dev hub - human readable results - no results', function () { | ||
// fake package ID | ||
const command = `force:package1:beta:version:display -i 04t46000001ZfaXXXX -u ${usernameOrAlias}`; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout as string; | ||
expect(output).to.contain('No results found'); | ||
}); | ||
|
||
it('should validate packageversionid flag (too short)', function () { | ||
// fake package ID - too short | ||
const command = `force:package1:beta:version:display -i 04t46000001Zfa -u ${usernameOrAlias}`; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const output = execCmd(command, { ensureExitCode: 1 }).shellOutput.stderr as string; | ||
expect(output).to.contain('Verify that you entered a valid package version ID (starts with 04t) and try again.'); | ||
}); | ||
|
||
it("should validate packageversionid flag (doesn't start with 04t)", function () { | ||
// fake package ID - not an 04t package | ||
const command = `force:package1:beta:version:display -i 05t46000001ZfaAAAS -u ${usernameOrAlias}`; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const output = execCmd(command, { ensureExitCode: 1 }).shellOutput.stderr as string; | ||
expect(output).to.contain('Verify that you entered a valid package version ID (starts with 04t) and try again.'); | ||
}); | ||
|
||
it('should list 1gp packages in dev hub - json', function () { | ||
const command = `force:package1:beta:version:display -i ${packageVersionId} -u ${usernameOrAlias} --json`; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
const output = execCmd<Package1Display[]>(command, { ensureExitCode: 0 }).jsonOutput.result[0]; | ||
expect(output).to.have.keys( | ||
'MetadataPackageVersionId', | ||
'MetadataPackageId', | ||
'Name', | ||
'Version', | ||
'ReleaseState', | ||
'BuildNumber' | ||
); | ||
expect(output.BuildNumber).to.be.a('number'); | ||
expect(output.ReleaseState).to.be.a('string'); | ||
expect(output.MetadataPackageVersionId).to.be.a('string'); | ||
expect(output.MetadataPackageId).to.be.a('string'); | ||
expect(output.Version).to.be.a('string'); | ||
}); | ||
}); |