Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@W-15398724@ Remove codeCoverage field from non-verbose query response for package version list #723

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/commands/package/version/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,17 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
record.AncestorId = 'N/A';
}

const codeCoverage =
record.CodeCoverage?.apexCodeCoveragePercentage != null
function getCodeCoverage(): string {
if (!flags.verbose) {
return 'use --verbose for code coverage';
}

return record.CodeCoverage?.apexCodeCoveragePercentage != null
? `${record.CodeCoverage.apexCodeCoveragePercentage.toString()}%`
: Boolean(record.Package2.IsOrgDependent) || record.ValidationSkipped
? 'N/A'
: '';
}

const hasPassedCodeCoverageCheck =
record.Package2.IsOrgDependent === true || record.ValidationSkipped
Expand Down Expand Up @@ -192,7 +197,7 @@ export class PackageVersionListCommand extends SfCommand<PackageVersionListComma
CreatedDate: new Date(record.CreatedDate).toISOString().replace('T', ' ').substring(0, 16),
LastModifiedDate: new Date(record.LastModifiedDate).toISOString().replace('T', ' ').substring(0, 16),
InstallUrl: INSTALL_URL_BASE.toString() + record.SubscriberPackageVersionId,
CodeCoverage: codeCoverage,
CodeCoverage: getCodeCoverage(),
HasPassedCodeCoverageCheck: hasPassedCodeCoverageCheck as string | boolean,
ValidationSkipped: record.ValidationSkipped,
ValidatedAsync: record.ValidatedAsync,
Expand Down
5 changes: 4 additions & 1 deletion test/commands/package/packageVersion.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ describe('package:version:*', () => {
});
it('should list package versions in dev hub - json results', () => {
const command = `package:version:list -v ${session.hubOrg.username} --json`;
const output = execCmd<[PackageVersionListCommandResult]>(command, { ensureExitCode: 0 }).jsonOutput?.result;
const output = execCmd<PackageVersionListCommandResult>(command, { ensureExitCode: 0 }).jsonOutput?.result;
const keys = [
'Package2Id',
'Branch',
Expand Down Expand Up @@ -345,7 +345,10 @@ describe('package:version:*', () => {
];
expect(output).to.have.length.greaterThan(0);
expect(output?.at(0)).to.have.keys(keys);
const codeCoverage = output?.[0]?.CodeCoverage;
expect(codeCoverage).to.equal('use --verbose for code coverage');
});

it('should list package versions in dev hub - verbose json results', () => {
const command = `package:version:list --verbose -v ${session.hubOrg.username} --json`;
const output = execCmd<PackageVersionListCommandResult>(command, { ensureExitCode: 0 }).jsonOutput
Expand Down
Loading