Removed commented-out tests to clean up the codebase. Added a new test to verify behavior when the file is closed early during attachment, ensuring robustness.
Introduce new unit tests for verifying the `AttachReader` method and enhancing error handling in attachment functions. These tests cover scenarios for success, file permissions, and early file closure errors.
Replace t.Skip with t.Log to avoid skipping tests and ensure they log their status. Introduce a comprehensive test for the AttachFile method, covering cases with existing, non-existent files, and using options.
Replaced direct bytes.Buffer{} initialization with bytes.NewBuffer(nil) for better consistency and potential performance improvements. This refactor affects both the HTML and plain text alternative writers.
Include various scenarios like default, with existing body string, nil template, and invalid template. These tests help in validating the addition of alternative text templates to messages.
Corrected the expected number of parts in an existing test from 1 to 2. Additionally, introduced tests for adding HTML templates to message bodies, including cases with a valid template, a body string, a nil template, and an invalid template.
Introduced tests for AddAlternativeString and AddAlternativeWriter methods, including variations for charset, encoding, content description, and simultaneous usages. Ensure accurate handling of content types, encodings, and body strings. This enhances coverage and reliability of message formatting features.
Implemented thorough unit tests to validate the SetBodyTextTemplate method in msg_test.go. These tests cover default behavior, handling of nil templates, and invalid templates, ensuring robustness and reliability.
Replace `bytes.Buffer{}` with `bytes.NewBuffer(nil)` for buffer instantiation to improve clarity and consistency. This change simplifies the buffer creation process and aligns it with common Go practices.
Introduced new tests to validate the functionality of `SetBodyWriter` with `WithPartEncoding` and `WithPartContentDescription`. Also added comprehensive tests for `SetBodyHTMLTemplate`, covering default behavior and error cases.
Change buffer initialization from an empty `bytes.Buffer` to `bytes.NewBuffer(nil)` to streamline buffer allocation. This adjustment ensures better flexibility and aligns with best practices in handling buffer slices.
Removed redundant and commented-out test functions to improve code readability and maintainability. Moved the essential helper functions (checkAddrHeader and checkGenHeader) to the end to keep the structure organized.
Updated the skip message to accurately reflect the timeout reason when closing the test server connection. This improves the clarity of the error reporting in tests.
Added a check in the client cleanup function to skip the test if the client connection fails due to a timeout. This ensures that network-related timeouts do not cause test failures, providing more reliable test outcomes.
Added GoLand directive to suppress deprecation warnings for SetAttachements method in msg_test.go. This method is already fully tested by SetAttachments and the test is marked to be skipped.
Introduced new test cases for ContentType values to ensure proper handling. Additionally, simplified multiple error messages in existing tests to enhance readability and maintain consistency.
Introduce tests for `SetEmbeds` with single, multiple, and no files. Add `UnsetAllEmbeds` and `UnsetAllParts` tests to ensure embeds and attachments are removed correctly.
Introduced tests for embedding files and managing attachments in messages. Validated behavior for setting and unsetting attachments and retrieving embedded files with various scenarios.
Implemented comprehensive tests for SetAttachments including scenarios with single, multiple, and no files. Additionally, deprecated the SetAttachements function and noted it as fully tested by SetAttachments.
Eliminated the TestMsg_SetAttachments function from the test suite as it duplicates functionality covered by other tests. Removing this redundant code improves maintainability and clarity.
Introduced a new test case to check `GetAttachments` when no attachments are present in the message object. Removed the redundant `TestMsg_GetAttachments` function to simplify the test suite.
This commit introduces unit tests for the GetAttachments method in the Msg struct to ensure it correctly handles both single and multiple attachments. The tests verify the name and content of the attachments to validate the expected behavior.
Introduce comprehensive tests for the GetGenHeader and GetParts methods. These tests cover single and multiple values for headers, body parts retrieval, and edge cases such as nil values, ensuring robustness and correctness.
Introduced unit tests for GetFrom, GetFromString, GetTo, GetToString, GetCc, GetCcString, GetBcc, and GetBccString methods. These tests cover scenarios with single, multiple, and no addresses, ensuring correct functionality of email address retrieval methods.
Add unit tests for the GetAddrHeaderString function to verify correct behavior for various header types and address counts. These tests ensure the function correctly handles single and multiple addresses, as well as scenarios with no addresses.
Introduce a new test to validate the behavior of GetAddrHeader for handling multiple addresses (to, cc, bcc). This test ensures that the function correctly processes and returns the expected addresses in various headers.
Introduce unit tests for the GetAddrHeader function in the Msg struct. These tests cover various scenarios, including valid addresses and handling of headers like "from," "to," "cc," and "bcc."
Implemented comprehensive tests for the Msg.GetRecipients method, covering various scenarios such as recipients in "to", "cc", "bcc" fields and combinations of these. Ensured correct handling of each case and validation against expected recipient counts and specific addresses.
Ensured the file ends with a newline to comply with best practices. This change improves code readability and consistency with other files in the repository.
Implemented tests for `RequestMDNToFormat`, `RequestMDNAddTo`, and `RequestMDNAddToFormat` methods to ensure proper address handling. Added comprehensive `GetSender` method tests to verify sender retrieval in various scenarios. This enhances coverage and robustness of email message handling functionality.
Simplify the address handling for the "Disposition-Notification-To" header in msg.go. The code now directly reassigns the previously fetched addresses and ensures appending the new address effectively. This improves code readability and correctness in updating the header.
Add checks to initialize `genHeader` if it is nil in the RequestMDNTo method to prevent potential nil map assignment errors. The newly implemented tests showed that this method was never actually working and the old test was inefficient to identify this.
Introduce tests for SetImportance, SetOrganization, SetUserAgent, and IsDelivered methods in the Msg type. These additions ensure the correct behavior and robustness of the email handling functionality.
Added a conditional check to ensure 'NewMsg()' does not return nil in the 'testMessage' helper function. This update will prevent potential nil pointer dereferences and improve the robustness of the test.
Relocated the `isDelivered` flag update to occur after the writer's close method validation. This ensures that the message delivery status is only marked as true if no errors arise during the writer close process. This showed up in the new test cases that covered errors on closing the DATA channel. This can already happen before the first byte is sent to the server. Therefore isDelivered should be set after a successful close.
Reformatted the test cases for European umlaut characters for consistency and readability. This change does not affect the execution or output of the tests.
Introduce tests for SetMessageIDWithValue, SetDate, and SetDateWithValue functions. Enhance coverage and validation for these methods by comparing generated headers and parsed dates.
Replaces direct time formatting in SetDate with a call to SetDateWithValue, improving code reusability and readability. The new approach centralizes date formatting logic in one method.
Introduce unit tests to ensure SetMessageID generates unique IDs and GetMessageID correctly formats various input IDs. Additionally, verify GetMessageID returns an empty string when no ID is set.
Added a test case for European umlaut characters in msg_test.go. Removed redundant test cases related to address handlers (To, Cc, Bcc) and other helper methods to streamline the code.
Introduced unit tests to verify the encoding of different character sets in the Msg.Subject() method. Tests include cases for Latin characters, Japanese, Simplified Chinese, Cyrillic, and Emoji to ensure proper encoding handling.
Implement new tests for the Msg.ReplyToFormat method to ensure it correctly handles both valid and invalid email addresses. These tests validate the ReplyTo header formatting and error handling.
Introduce unit tests for the `ReplyTo` method in the `Msg` struct to validate both correct handling of valid email addresses and proper failure responses for invalid ones. Further, refactor and add helper functions to check generated headers in messages.
Introduce comprehensive unit tests for Bcc functionalities, including validation of single and multiple addresses, various invalid input scenarios, and RFC5322 compliance checks. Additionally, implement tests for AddBcc, AddBccFormat, BccIgnoreInvalid, and BccFromString methods to ensure robust handling of different Bcc cases.
Trim spaces from email addresses and skip empty addresses in BccFromString method. This ensures that the BCC list only includes valid, non-empty email addresses, enhancing email sending reliability.
This commit introduces comprehensive tests for various "Cc" related methods in the `Msg` struct. It includes test cases for valid and invalid email addresses for methods: `Cc`, `AddCc`, `AddCcFormat`, `CcIgnoreInvalid`, and `CcFromString`, ensuring robust handling of different scenarios and edge cases.
This change ensures that email addresses with leading or trailing spaces are trimmed, and empty addresses resulting from multiple commas are ignored. This helps prevent potential errors with malformed email addresses in the "Cc" field.