• Ashaar Gautam 15
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
When setting your Dev Hub using SFDX does it have to be your production org?

Or can you set a sandbox as your Dev Hub?
 
  • August 05, 2020
  • Like
  • 0
@isTest
public class TestDataFactory {
   
    public static testMethod void testdata_for_manipulateDataForInviteBlast(){
        insert new Pardot_Settings__c(Name = 'Pardot User Key', User_Key__c ='xxxxxxxxxxxxxxxxxxx');
        
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGeneratorpost());
        Account a = new Account();
        
        a.Name = 'Test Account';
        Insert a;
       
        Contact con1 = new Contact();
        con1.FirstName='Seema';
        con1.LastName= 'singh';
        con1.AccountId = a.Id;        
        con1.Email='seemax1.singh@accelerize360.com';
        insert con1; 
        
        Analyst__c an= new Analyst__c();
        an.Name='asdf122345';
        an.Order_of_Precedence__c = '1';
        insert an;
        
        
        Custom_Event__c cEvent = new Custom_Event__c();
        cEvent.name = 'testingEvent';
        cEvent.CAT_external_event_name__c = 'testing External Event';
        cEvent.Type_of_Meeting__c = 'Analyst Marketing';
        cEvent.Start_Date__c = DateTime.Now().AddDays(10);
        cEvent.End_Date__c = DateTime.Now().AddDays(13);
        insert cEvent;
        
        Campaign com = new Campaign();
        com.Analyst__c=an.id;
        com.Related_Event__c = cEvent.Id;
        com.Name='test';
        insert com;
        
        CampaignMember cm = new CampaignMember();
        cm.ContactId=con1.id;
        cm.CampaignId=com.id;
        cm.CampaignId = com.id;
        insert cm;
        
         EmailMessage incomingMail = new EmailMessage();
         incomingMail.fromaddress='test@email.com';
         incomingMail.toAddress = 'test@test.com';
         incomingMail.subject = ' Test Message';
         incomingMail.TextBody= 'This is the message body ';
         incomingMail.RelatedToId = cEvent.id;
         insert incomingMail ;       
        
    }
}

here I'm not testing integration directly, but it was like whenever contact is created it happens, so its making callout indirectly that's why I have to use more class. 

here when I run the test I'm getting error:

System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

and when I remove emailmessage record insertion part its working. but I need that