Does Database.emptyRecycleBin
work as intended under test conditions?
The test below would suggest not as the actual row count is one instead of an expected zero. Have I missed something? I have already tried wrapping the act with Test.StartTest
/ Test.StopTest
on the assumption that purges run with a low priority asynchronously but to no avail.
@isTest
private class PurgeAccountTest{
private static testMethod void canPurgeAccount() {
// arrange
Account account = new Account(Name = 'Mike');
insert account;
List<Id> accountIds = new List<Id>{ account.Id };
delete account;
// act
Database.emptyRecycleBin(accountIds);
List<Account> accountsAfterPurge = [SELECT id, Name FROM Account ALL ROWS];
// assert
Integer expectedAfterPurgeCount = 0;
System.assertEquals(expectedAfterPurgeCount, accountsAfterPurge.size());
}
}