We are transitioning our org to LEX and there is code that has to be updated from Attachments to Files...i.e. ContentVersion, ContentDocument and ContentDocumentLink. One of the updates is a trigger that was on Attachments that ran on
beforeDelete that would use the
addError method to display a custom message to prevent Attachments from being inserted, updated or deleted when certain conditions where met during an approval process.
Based on some documentation I found, I created a new trigger on the ContentDocumentLink which has the LinkedEntityId reference field to the parent object that the attachment is related to. There appears to be a known issue that the custom error message does not display in LEX and instead displays a standard error message with
Unable to Upload Files, which is okay in this scenario. The custom message isn't mandatory. I've tested the code and it does appear to work for insert, update and delete. However, I'm working on the unit tests and I get coverage for the insert, but cannot get the code to fire for edit and delete.
Is it possible to cover an update and delete on the ContentDocumentLink trigger? What record do I need to update and delete to fire the trigger on the ContentDocumentLink in the unit test?