I am able to load the static resource but I am unable to insert the loaded accounts into salesforce. I want to do this to be able to test various methods that depend on first selecting a particular salesforce record and then perform some type of update logic on it.
I have a CSV in the following format added via static resources:
"WEBSITE","NAME","PHONE","BILLINGADDRESS","BILLINGCITY","BILLINGSTATE","BILLINGPOSTALCODE","BILLINGCOUNTRY"
"llemonaid.com","LEMONAID CO","316666665","33 A ST NW","CEDAR RAPIDS","IA","522222003","United States"
The following is my load and insert code that is failing with an error: System.DmlException: Insert failed. First exception on row 0 with id 001E000000z1iMpIAI; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
@isTest
private class MatchController_Tests
{
static testMethod void testUpdateAccountRecord()
{
MatchController controller = new MatchController();
List<sObject> accountsList = Test.loadData(Account.sObjectType, 'testAccounts');
List<Account> insertList = new List<Account>();
//Copying into another List was another attempt I made when the first
// List<sObject> failed to insert.
for (Integer i = 0; i < accountsList.size(); i++)
{
Account acct = (Account) accountsList[i];
insertList.add(acct);
}
System.assert(insertList.size() == 100);
insert insertList;
}
}