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

fix: allow varargs in the command #380

Merged
merged 1 commit into from
Jan 23, 2023
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
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;
});
});
});