Skip to content

Commit d0d96c8

Browse files
authored
Fix: Prevent CRUD/FLS Errors in Unit Tests (#130)
* reproducing the problem * first pass at solution * removing dependency on User DML
1 parent 8b95bf4 commit d0d96c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

source/classes/SoqlTest.cls

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,10 @@ private class SoqlTest {
16311631
}
16321632

16331633
private static Object validateQuery(Soql soql, String expected) {
1634-
Assert.areEqual('"' + expected + '"', '"' + soql?.toString() + '"', 'Unexpected SOQL output');
1634+
Assert.areEqual('"' + expected + '"', '"' + soql + '"', 'Unexpected SOQL output');
1635+
// This test will always run the queries in system mode to prevent FLS/CRUD errors
1636+
// when the test is run by non-admin users (ex., CICD integrations w/minimal object access)
1637+
soql?.setAccessLevel(System.AccessLevel.SYSTEM_MODE);
16351638
return soql?.query();
16361639
}
16371640

0 commit comments

Comments
 (0)