Last active
June 5, 2023 02:52
-
-
Save nickforce/301785393a91284e2464d8f0c3df3d86 to your computer and use it in GitHub Desktop.
Bard Unit Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest | |
private class ProcessContacts_Test { | |
@testSetup static void setup() { | |
// Create contact record | |
List<Contact> testContacts = new List<Contact>(); | |
for(Integer i=0;i<1;i++) { | |
testContacts.add(new Contact(FirstName = 'GoogleBard'+i, | |
LastName = 'Test')); | |
} | |
insert testContacts; | |
} | |
@isTest static void email_updated_date() { | |
// Get the first Contact from testSetup data | |
Contact varContact = [SELECT Email | |
FROM Contact | |
WHERE FirstName='GoogleBard0' | |
LIMIT 1]; | |
// Verify that test contact Email is null. | |
System.assertEquals(null, varContact.Email); | |
Test.startTest(); | |
// Update the contacts email field to a new value | |
varContact.Email = 'update.bard@ai.com'; | |
update varContact; | |
Test.stopTest(); | |
// Assert the Bard generated trigger worked as expected | |
System.assertEquals(System.now(), | |
[SELECT Email_Updated_Date__c | |
FROM Contact | |
WHERE FirstName = 'GoogleBard0'] | |
.Email_Updated_Date__c); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment