Skip to content

Commit

Permalink
fix: testing demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevmo92 committed Dec 17, 2024
1 parent 35e8162 commit f2eb165
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 39 deletions.
5 changes: 5 additions & 0 deletions READEME.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Demo repo for sf core vs jsforce

Repo was created for the purpose of showing the difference between installing a package with the tooling api after connecting with either sf core or jsforce

When installing a package with a jsforce connection and then running a unit test involving permissions the permissions are different than when installing a package with salesforce/core connection.
6 changes: 0 additions & 6 deletions src/demo/classes/Application.cls
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
public class Application {
public static APermissionHelper Permissions = new CustomPermissionHelper();

public static String generateLookupKey() {
String returnVal = Math.random() + '';
returnVal = returnVal.replace('0.', '42');
return returnVal.substring(0, Math.min(returnVal.length(), 17));
}
}
3 changes: 1 addition & 2 deletions src/demo/classes/CustomPermissionHelper.cls
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public class CustomPermissionHelper extends APermissionHelper {
];
}

public class CustomPermissionNotFoundException extends Exception {
}
public class CustomPermissionNotFoundException extends Exception {}

private static final String PERMISSION_NOT_FOUND_MESSAGE = 'Custom Permission ({0}) not found.';
}
2 changes: 1 addition & 1 deletion src/demo/classes/CustomPermissionHelperTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public class CustomPermissionHelperTest {
System.assertEquals(false, actualValue);
}

private static final String LOCAL_CUSTOM_PERMISSION = 'Generate_Release_Notes';
private static final String LOCAL_CUSTOM_PERMISSION = 'Demo_Baby';
}
25 changes: 0 additions & 25 deletions src/demo/classes/UnitTestUtility.cls
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,4 @@ public with sharing class UnitTestUtility {
insert newUser;
return newUser;
}

@TestVisible
private static User createUser(String userAlias, String userName, String profileName, String[] permissionSets) {
User newUser = UnitTestUtility.createUser(userAlias, userName, profileName);

PermissionSetAssignment[] assignments = new List<PermissionSetAssignment>{};

for (String permissionSetName : permissionSets) {
PermissionSet permSet = UnitTestUtility.getPermissionSet(permissionSetName);
assignments.add(new PermissionSetAssignment(AssigneeId = newUser.Id, PermissionSetId = permSet.Id));
}

insert assignments;
return newUser;
}

@TestVisible
private static User getUser(String alias) {
return [SELECT Id, Name FROM User WHERE Alias = :alias LIMIT 1];
}

@TestVisible
private static PermissionSet getPermissionSet(String name) {
return [SELECT Id, Name FROM PermissionSet WHERE Name = :name LIMIT 1];
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomPermission xmlns="http://soap.sforce.com/2006/04/metadata">
<description>Grants the ability to generate release notes.</description>
<label>Generate Release Notes</label>
<description>This is just a demo</description>
<label>Demo Baby</label>
</CustomPermission>
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
</applicationVisibilities>
<customPermissions>
<enabled>true</enabled>
<name>Generate_Release_Notes</name>
<name>Demo_Baby</name>
</customPermissions>
<description>Grants the ability to generate automated release note. Intended for use ONLY by Data Integration Developers</description>
<description>This is just a demo</description>
<hasActivationRequired>false</hasActivationRequired>
<label>Automated Release Notes</label>
<label>Demo Baby</label>
</PermissionSet>

0 comments on commit f2eb165

Please sign in to comment.