apex-mutation-testing
Version:
Apex mutation testing plugin
34 lines • 1.11 kB
JavaScript
export class ApexClassRepository {
connection;
constructor(connection) {
this.connection = connection;
}
async read(name) {
return (await this.connection.tooling
.sobject('ApexClass')
.find({ Name: name })
.execute())[0];
}
async update(apexClass) {
const container = await this.connection.tooling
.sobject('MetadataContainer')
.create({
Name: `MutationTest_${Date.now()}`,
});
// Create ApexClassMember for the mutated version
await this.connection.tooling.sobject('ApexClassMember').create({
MetadataContainerId: container.id,
ContentEntityId: apexClass.Id,
Body: apexClass.Body,
});
// Create ContainerAsyncRequest to deploy
return await this.connection.tooling
.sobject('ContainerAsyncRequest')
.create({
IsCheckOnly: false,
MetadataContainerId: container.id,
IsRunTests: true,
});
}
}
//# sourceMappingURL=apexClassRepository.js.map