function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SpacesiftSpacesift 

sendgrid-apex unmanaged package preventing deploy to production

Preface - I'm the using sendgrid-apex unmanaged package here - https://github.com/sendgrid/sendgrid-apex
I've written a very simple class in sandbox that allows me to send emails via SendGrid. I deployed to staging successfully, but upon attempting to deploy in production, I received 4 error messages. There are a couple things odd about this:

1) This has been untouched for 3 years and to think that these errors have been here all along is ludicrous to me (though maybe winter 17 broke something)
2) In the second attempt at a changeset, I didn't include the class dependencies that were creating the errors, however the errors still prevented a successful deploy even though the classes are existing in production and are not part of the changeset

Below are the errors i'm seeing...

SendGridTest
testAddHeader
System.AssertException: Assertion Failed: Expected: &headers=%7B%22key%22%3A%22value%22%2C%22other%22%3A%22other-value%22%7D, Actual: &headers=%7B%22other%22%3A%22other-value%22%2C%22key%22%3A%22value%22%7D 
Stack Trace: Class.SendGridTest.testAddHeader: line 190, column 1

SendGridTest
testAddSection
System.AssertException: Assertion Failed: Expected: &x-smtpapi=%7B%22section%22%3A%7B%22set_section_key%22%3A%22set_section_value%22%2C%22set_section_key_2%22%3A%22set_section_value_2%22%7D%7D, Actual: &x-smtpapi=%7B%22section%22%3A%7B%22set_section_key_2%22%3A%22set_section_value_2%22%2C%22set_section_key%22%3A%22set_section_value%22%7D%7D 
Stack Trace: Class.SendGridTest.testAddSection: line 171, column 1

SmtpapiTest
setSetFilters
System.AssertException: Assertion Failed: Expected: {"filters":{"footer":{"settings":{"enable":"1","text/plain":"You can haz footers!"}}}}, Actual: {"filters":{"footer":{"settings":{"text/plain":"You can haz footers!","enable":"1"}}}} 
Stack Trace: Class.SmtpapiTest.setSetFilters: line 116, column 1

SmtpapiTest
testAddSection
System.AssertException: Assertion Failed: Expected: {"section":{"set_section_key":"set_section_value","set_section_key_2":"set_section_value_2"}}, Actual: {"section":{"set_section_key_2":"set_section_value_2","set_section_key":"set_section_value"}} 
Stack Trace: Class.SmtpapiTest.testAddSection: line 80, column 1
Best Answer chosen by Spacesift
Chris Gary CloudPerformerChris Gary CloudPerformer
Hello,
It is not surprising that these might throw errors in a three year old unmanaged package.  Without knowing or looking at the unmanaged package contents, I can tell you that since these are assertion errors, the assertions themselves can be commented out and these errors will stop.  Assertions are not necessary for deployment, and not necessary for code coverage. The real question is 'do the test methods execute at least 75% of the code successfully'? Assertions are definitely good programming practice, but not required for code coverage deployment.
I hope this helps. 
Once your issue is resolved, please remember to mark a comment as 'Best Answer' (even if it is not this one). It will mark this question as resolved and that helps the community!