Skip to content

Commit

Permalink
fix: allow varargs in the command (#380)
Browse files Browse the repository at this point in the history
@W-12421083@
  • Loading branch information
peternhale authored Jan 23, 2023
1 parent c713071 commit 82680a2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/commands/generate/cmdt/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface CmdtRecordCreateResponse {
fileData: CustomField[];
}
export default class Create extends SfCommand<CmdtRecordCreateResponse> {
public static readonly strict = false;
public static readonly summary = messages.getMessage('summary');
public static readonly description = messages.getMessage('description');
public static readonly requiresProject = true;
Expand Down
36 changes: 36 additions & 0 deletions test/nuts/local/createRecord.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,41 @@ describe('cmdt record create', () => {
expect(xml.includes('<type>Checkbox</type>')).to.be.true;
expect(xml.includes('<defaultValue>false</defaultValue>')).to.be.true;
});
it('should create records without optional flags and field values', async () => {
const testDir = 'outputTestDir';
const fieldDirPath = path.join(testDir, 'Output_Test__mdt', 'fields');
const filePath = path.join(projDir, fieldDirPath, 'Check__c.field-meta.xml');
const recordFilePath = path.join(
projDir,
testDir,
'customMetadata',
'Output_Test.Output_Test_Record.md-meta.xml'
);
const outputDir = path.join(testDir, 'Output_Test__mdt');
execCmd(`force:cmdt:create --typename Output_Test --outputdir ${testDir}`, { ensureExitCode: 0 });
execCmd(`force:cmdt:field:create --fieldname Check --fieldtype Checkbox --outputdir ${outputDir}`, {
ensureExitCode: 0,
});
execCmd(
`force:cmdt:record:create -t Output_Test -n Output_Test_Record -i ${testDir} -d ${path.join(
testDir,
'customMetadata'
)} Check__c=true`,
{ ensureExitCode: 0 }
);
expect(fs.existsSync(path.join(projDir, fieldDirPath))).to.be.true;
expect(fs.existsSync(filePath)).to.be.true;

const xml = await fs.promises.readFile(filePath, { encoding: 'utf-8' });
expect(xml.includes('<fullName>Check__c</fullName>')).to.be.true;
expect(xml.includes('<fieldManageability>DeveloperControlled</fieldManageability>')).to.be.true;
expect(xml.includes('<label>Check</label>')).to.be.true;
expect(xml.includes('<type>Checkbox</type>')).to.be.true;
expect(xml.includes('<defaultValue>false</defaultValue>')).to.be.true;
const recordXml = await fs.promises.readFile(recordFilePath, { encoding: 'utf-8' });
expect(recordXml.includes('<label>Output_Test_Record</label>')).to.be.true;
expect(recordXml.includes('<field>Check__c</field>')).to.be.true;
expect(/<value.*?>true<\/value>/.test(recordXml)).to.be.true;
});
});
});

0 comments on commit 82680a2

Please sign in to comment.