Skip to content

Commit

Permalink
fix: conditionally include folder (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel authored Nov 23, 2021
1 parent 4a186e5 commit 6a7c936
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/commands/force/mdapi/listmetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export class ListMetadata extends SourceCommand {

this.validateResultFile();

const query: ListMetadataQuery = { type, folder };
const query: ListMetadataQuery = { type };
if (folder) {
query.folder = folder;
}
const connection = this.org.getConnection();
const result = (await connection.metadata.list(query, apiversion)) || [];
this.listResult = Array.isArray(result) ? result : [result];
Expand Down
12 changes: 11 additions & 1 deletion test/nuts/mdapi.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ describe('mdapi NUTs', () => {
});

describe('mdapi:listmetadata', () => {
it('should successfully execute listmetadata', () => {
it('should successfully execute listmetadata for type CustomObject', () => {
const result = execCmd('force:mdapi:listmetadata --json --metadatatype CustomObject');
expect(result.jsonOutput.status).to.equal(0);
expect(result.jsonOutput.result).to.be.an('array').with.length.greaterThan(100);
expect(result.jsonOutput.result[0]).to.have.property('type', 'CustomObject');
});

it('should successfully execute listmetadata for type ListView', () => {
// ListView is sensitive to how the connection.metadata.list() call is made.
// e.g., if you pass { type: 'ListView', folder: undefined } it will not return
// any ListViews but if you pass { type: 'ListView' } it returns all ListViews.
const result = execCmd('force:mdapi:listmetadata --json --metadatatype ListView');
expect(result.jsonOutput.status).to.equal(0);
expect(result.jsonOutput.result).to.be.an('array').with.length.greaterThan(10);
expect(result.jsonOutput.result[0]).to.have.property('type', 'ListView');
});
});

describe('mdapi:describemetadata', () => {
Expand Down

0 comments on commit 6a7c936

Please sign in to comment.