File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
force-app/main/default/classes/main/cached-soql Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -580,6 +580,27 @@ private class SOQLCache_Test {
580580 Assert .isTrue (((List <SOQLCache .CacheItem >) CacheManager .SOQLOrgCache .get (' Profile' )).isEmpty (), ' Cache items should be empty.' );
581581 }
582582
583+ @IsTest
584+ static void emptyRecordsClearedFromCache () {
585+ // Setup
586+ Profile profile = (Profile ) SOQLCache .of (Profile .SObjectType )
587+ .with (Profile .Id , Profile .Name )
588+ .whereEqual (Profile .Name , ' System Administrator' )
589+ .cacheInOrgCache ()
590+ .toObject ();
591+
592+ // Verify initial setup
593+ Assert .isTrue (CacheManager .SOQLOrgCache .contains (' Profile' ), ' Key should exist.' );
594+ Assert .isFalse (((List <SOQLCache .CacheItem >) CacheManager .SOQLOrgCache .get (' Profile' )).isEmpty (), ' Cache item should be present.' );
595+
596+ // Test
597+ SOQLCache .refreshRecords (new List <Profile >());
598+
599+ // Verify
600+ Assert .isTrue (CacheManager .SOQLOrgCache .contains (' Profile' ), ' Key should still exist.' );
601+ Assert .isFalse (((List <SOQLCache .CacheItem >) CacheManager .SOQLOrgCache .get (' Profile' )).isEmpty (), ' Cache items should be not empty.' );
602+ }
603+
583604 static User minimumAccessUser () {
584605 return new User (
585606 Alias = ' newUser' ,
You can’t perform that action at this time.
0 commit comments