Skip to content

Commit 5b7bc20

Browse files
committed
additional test
Signed-off-by: Piotr PG Gajek <[email protected]>
1 parent 3e46315 commit 5b7bc20

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

force-app/main/default/classes/main/cached-soql/SOQLCache_Test.cls

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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',

0 commit comments

Comments
 (0)