Skip to content

Commit

Permalink
Simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aheber committed Nov 27, 2024
1 parent a866534 commit d33aa47
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 24 deletions.
19 changes: 8 additions & 11 deletions dlrs/main/classes/RollupCalculateJobTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -261,17 +261,14 @@ private class RollupCalculateJobTest {

RollupCalculateJob job = new RollupCalculateJob(rollupCfg.Id, 'Id != NULL');
String jobId;
System.runAs(new User(Id = UserInfo.getUserId())) {
Test.startTest();
Assert.areEqual(
true,
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(job);
Test.stopTest();
}
Test.startTest();
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(job);
Test.stopTest();

AsyncApexJob asyncJob = [
SELECT Id, Status, JobItemsProcessed, TotalJobItems
Expand Down
19 changes: 8 additions & 11 deletions dlrs/main/classes/RollupJobTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -251,17 +251,14 @@ private class RollupJobTest {
insert items;

String jobId;
System.runAs(new User(Id = UserInfo.getUserId())) {
Test.startTest();
Assert.areEqual(
true,
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(new RollupJob());
Test.stopTest();
}
Test.startTest();
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
// go into runAs because we need to get the perms recalculated
jobId = Database.executeBatch(new RollupJob());
Test.stopTest();

AsyncApexJob asyncJob = [
SELECT Id, Status, JobItemsProcessed, TotalJobItems
Expand Down
3 changes: 1 addition & 2 deletions dlrs/main/classes/UtilitiesTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public class UtilitiesTest {
if (String.isNotBlank(perm.NamespacePrefix)) {
permName = perm.NamespacePrefix + '__' + perm.DeveloperName;
}
Assert.areEqual(
true,
Assert.isTrue(
Utilities.userHasCustomPermission(permName),
'Expected user to have ' + permName
);
Expand Down

0 comments on commit d33aa47

Please sign in to comment.